aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/image.class.php
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-04-29 17:10:00 +0000
committerpatdenice <patdenice@piwigo.org>2011-04-29 17:10:00 +0000
commit90825d08ea8c6af10aadc2067cf8fbf125c8a29f (patch)
tree4526c7594bd9ce3d9d4f0c47ae5af406fc7e75b1 /admin/include/image.class.php
parent920f8b443a300d2d2fa429b8188efec10314dd97 (diff)
feature:2284
Rename $conf['image_library'] into $conf['graphics_library'] Display library used in admin intro page. git-svn-id: http://piwigo.org/svn/trunk@10684 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/image.class.php')
-rw-r--r--admin/include/image.class.php77
1 files changed, 41 insertions, 36 deletions
diff --git a/admin/include/image.class.php b/admin/include/image.class.php
index 943c2a257..0fa851636 100644
--- a/admin/include/image.class.php
+++ b/admin/include/image.class.php
@@ -57,8 +57,6 @@ class pwg_image
function __construct($source_filepath, $library=null)
{
- global $conf;
-
$this->source_filepath = $source_filepath;
trigger_action('load_image_library', array(&$this) );
@@ -75,40 +73,9 @@ class pwg_image
die('[Image] unsupported file extension');
}
- if (is_null($library))
+ if (!($this->library = self::get_library($library, $extension)))
{
- $library = $conf['image_library'];
- }
-
- // Choose image library
- switch (strtolower($library))
- {
- case 'auto':
- case 'imagick':
- if ($extension != 'gif' and self::is_imagick())
- {
- $this->library = 'imagick';
- break;
- }
- case 'ext_imagick':
- if ($extension != 'gif' and self::is_ext_imagick())
- {
- $this->library = 'ext_imagick';
- break;
- }
- case 'gd':
- if (self::is_gd())
- {
- $this->library = 'gd';
- break;
- }
- default:
- if ($library != 'auto')
- {
- // Requested library not available. Try another library
- return self::__construct($source_filepath, 'auto');
- }
- die('No image library available on your server.');
+ die('No image library available on your server.');
}
$class = 'image_'.$this->library;
@@ -304,7 +271,7 @@ class pwg_image
{
return false;
}
- @exec($conf['ext_imagick_dir'].'convert', $returnarray, $returnvalue);
+ @exec($conf['ext_imagick_dir'].'convert -version', $returnarray, $returnvalue);
if (!$returnvalue and !empty($returnarray[0]) and preg_match('/ImageMagick/i', $returnarray[0]))
{
return true;
@@ -317,6 +284,44 @@ class pwg_image
return function_exists('gd_info');
}
+ static function get_library($library=null, $extension=null)
+ {
+ global $conf;
+
+ if (is_null($library))
+ {
+ $library = $conf['image_library'];
+ }
+
+ // Choose image library
+ switch (strtolower($library))
+ {
+ case 'auto':
+ case 'imagick':
+ if ($extension != 'gif' and self::is_imagick())
+ {
+ return 'imagick';
+ }
+ case 'ext_imagick':
+ if ($extension != 'gif' and self::is_ext_imagick())
+ {
+ return 'ext_imagick';
+ }
+ case 'gd':
+ if (self::is_gd())
+ {
+ return 'gd';
+ }
+ default:
+ if ($library != 'auto')
+ {
+ // Requested library not available. Try another library
+ return self::get_library('auto');
+ }
+ }
+ return false;
+ }
+
function destroy()
{
if (method_exists($this->image, 'destroy'))