summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-02 11:57:20 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-02 11:57:20 -0700
commitb9293755c03a6bf55a33732968481aa7a73fcce0 (patch)
treeea03aaec92da1a0a14ef80cd73fecafbf8071716
parent79754c2ef477c98740166a2a86fb491e0b07944e (diff)
Deal with the aftermath of adding sharpen() calls. Since GD does not
support it, this causes crashes as soon as you try to use it, which breaks a bunch of our tests. Also, give the user some idea that sharpen() is missing in the UI. Fixes #689.
-rw-r--r--modules/gallery/helpers/graphics.php37
1 files changed, 27 insertions, 10 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 521dc5a4..66182a68 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -206,11 +206,13 @@ class graphics_Core {
// Image would get upscaled; do nothing
copy($input_file, $output_file);
} else {
- Image::factory($input_file)
+ $image = Image::factory($input_file)
->resize($options["width"], $options["height"], $options["master"])
- ->quality(module::get_var("gallery", "image_quality"))
- ->sharpen(module::get_var("gallery", "image_sharpen"))
- ->save($output_file);
+ ->quality(module::get_var("gallery", "image_quality"));
+ if (graphics::can("sharpen")) {
+ $image->sharpen(module::get_var("gallery", "image_sharpen"));
+ }
+ $image->save($output_file);
}
module::event("graphics_resize_completed", $input_file, $output_file, $options);
@@ -352,13 +354,22 @@ class graphics_Core {
$toolkits->gd->installed = true;
$toolkits->gd->version = $gd["GD Version"];
$toolkits->gd->rotate = function_exists("imagerotate");
+ $toolkits->gd->sharpen = function_exists("imageconvolution");
$toolkits->gd->binary = "";
$toolkits->gd->dir = "";
- if (!$toolkits->gd->rotate) {
+ if (!$toolkits->gd->rotate && !$toolkits->gd->sharpen) {
+ $toolkits->gd->error =
+ t("You have GD version %version, but it lacks image rotation and sharpening.",
+ array("version" => $gd["GD Version"]));
+ } else if (!$toolkits->gd->rotate) {
$toolkits->gd->error =
t("You have GD version %version, but it lacks image rotation.",
array("version" => $gd["GD Version"]));
+ } else if (!$toolkits->gd->sharpen) {
+ $toolkits->gd->error =
+ t("You have GD version %version, but it lacks image sharpening.",
+ array("version" => $gd["GD Version"]));
}
}
@@ -387,6 +398,7 @@ class graphics_Core {
$toolkits->imagemagick->binary = $path;
$toolkits->imagemagick->dir = dirname($path);
$toolkits->imagemagick->rotate = true;
+ $toolkits->imagemagick->sharpen = true;
} else {
$toolkits->imagemagick->installed = false;
$toolkits->imagemagick->error =
@@ -411,6 +423,7 @@ class graphics_Core {
$toolkits->graphicsmagick->binary = $path;
$toolkits->graphicsmagick->dir = dirname($path);
$toolkits->graphicsmagick->rotate = true;
+ $toolkits->graphicsmagick->sharpen = true;
} else {
$toolkits->graphicsmagick->installed = false;
$toolkits->graphicsmagick->error =
@@ -475,14 +488,18 @@ class graphics_Core {
/**
* Verify that a specific graphics function is available with the active toolkit.
- * @param string $func (eg rotate, resize)
+ * @param string $func (eg rotate, sharpen)
* @return boolean
*/
static function can($func) {
- if (module::get_var("gallery", "graphics_toolkit") == "gd" &&
- $func == "rotate" &&
- !function_exists("imagerotate")) {
- return false;
+ if (module::get_var("gallery", "graphics_toolkit") == "gd") {
+ switch ($func) {
+ case "rotate":
+ return function_exists("imagerotate");
+
+ case "sharpen":
+ return function_exists("imageconvolution");
+ }
}
return true;