summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/graphics.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers/graphics.php')
-rw-r--r--modules/gallery/helpers/graphics.php88
1 files changed, 35 insertions, 53 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index edba6b76..72c563b7 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -313,60 +313,42 @@ class graphics_Core {
$toolkits->graphicsmagick->installed = false;
$toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function");
} else {
- gallery::set_path_env(
- array(module::get_var("gallery", "graphics_toolkit_path"),
- getenv("PATH"),
- module::get_var("gallery", "extra_binary_paths")));
-
- // @todo: consider refactoring the two segments below into a loop since they are so
- // similar.
-
- // ImageMagick
- $path = exec("which convert");
- $toolkits->imagemagick->name = "ImageMagick";
- if ($path) {
- if (@is_file($path)) {
- preg_match('/Version: \S+ (\S+)/', `convert -v`, $matches);
- $version = $matches[1];
-
- $toolkits->imagemagick->installed = true;
- $toolkits->imagemagick->version = $version;
- $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 =
- t("ImageMagick is installed, but PHP's open_basedir restriction prevents Gallery from using it.");
- }
- } else {
- $toolkits->imagemagick->installed = false;
- $toolkits->imagemagick->error = t("We could not locate ImageMagick on your system.");
- }
-
- // GraphicsMagick
- $path = exec("which gm");
- $toolkits->graphicsmagick->name = "GraphicsMagick";
- if ($path) {
- if (@is_file($path)) {
- preg_match('/\S+ (\S+)/', `gm version`, $matches);
- $version = $matches[1];
-
- $toolkits->graphicsmagick->installed = true;
- $toolkits->graphicsmagick->version = $version;
- $toolkits->graphicsmagick->binary = $path;
- $toolkits->graphicsmagick->dir = dirname($path);
- $toolkits->graphicsmagick->rotate = true;
- $toolkits->graphicsmagick->sharpen = true;
+ // ImageMagick & GraphicsMagick
+ $magick_kits = array(
+ "imagemagick" => array(
+ "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v",
+ "version_regex" => "/Version: \S+ (\S+)/"),
+ "graphicsmagick" => array(
+ "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version",
+ "version_regex" => "/\S+ (\S+)/"));
+ // Loop through the kits
+ foreach ($magick_kits as $index => $settings) {
+ $path = system::find_binary(
+ $settings["binary"], module::get_var("gallery", "graphics_toolkit_path"));
+ $toolkits->$index->name = $settings["name"];
+ if ($path) {
+ if (@is_file($path) &&
+ preg_match($settings["version_regex"], shell_exec($settings["version"]), $matches)) {
+ $version = $matches[1];
+
+ $toolkits->$index->installed = true;
+ $toolkits->$index->version = $version;
+ $toolkits->$index->binary = $path;
+ $toolkits->$index->dir = dirname($path);
+ $toolkits->$index->rotate = true;
+ $toolkits->$index->sharpen = true;
+ } else {
+ $toolkits->$index->installed = false;
+ $toolkits->$index->error =
+ t("%toolkit_name is installed, but PHP's open_basedir restriction prevents Gallery from using it.",
+ array("toolkit_name" => $settings["name"]));
+ }
} else {
- $toolkits->graphicsmagick->installed = false;
- $toolkits->graphicsmagick->error =
- t("GraphicsMagick is installed, but PHP's open_basedir restriction prevents Gallery from using it.");
+ $toolkits->$index->installed = false;
+ $toolkits->$index->error =
+ t("We could not locate %toolkit_name on your system.",
+ array("toolkit_name" => $settings["name"]));
}
- } else {
- $toolkits->graphicsmagick->installed = false;
- $toolkits->graphicsmagick->error = t("We could not locate GraphicsMagick on your system.");
}
}