diff options
author | colings <colings@example.com> | 2011-02-13 10:46:43 -0600 |
---|---|---|
committer | colings <colings@example.com> | 2011-02-13 10:46:43 -0600 |
commit | d759d47ef99ebde158620f43ab46a83f445d9e53 (patch) | |
tree | 4b4f9a53d721ac02e8762d9c543ad479faa97bae /modules/gallery/helpers/graphics.php | |
parent | 02a349f68ac480d5b1a630e14b4f2e3558328673 (diff) | |
parent | d2c77fd0590501f7b6b51d9f4cc033ed9485b082 (diff) |
Merge remote branch 'upstream/master'
Diffstat (limited to 'modules/gallery/helpers/graphics.php')
-rw-r--r-- | modules/gallery/helpers/graphics.php | 88 |
1 files changed, 35 insertions, 53 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index bfea2f2c..834211bf 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 @@ -315,60 +315,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."); } } |