Changeset 10684 for trunk/admin/include


Ignore:
Timestamp:
Apr 29, 2011, 7:10:00 PM (13 years ago)
Author:
patdenice
Message:

feature:2284
Rename $confimage_library into $confgraphics_library
Display library used in admin intro page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/image.class.php

    r10641 r10684  
    5858  function __construct($source_filepath, $library=null)
    5959  {
    60     global $conf;
    61 
    6260    $this->source_filepath = $source_filepath;
    6361
     
    7674    }
    7775
    78     if (is_null($library))
    79     {
    80       $library = $conf['image_library'];
    81     }
    82 
    83     // Choose image library
    84     switch (strtolower($library))
    85     {
    86       case 'auto':
    87       case 'imagick':
    88         if ($extension != 'gif' and self::is_imagick())
    89         {
    90           $this->library = 'imagick';
    91           break;
    92         }
    93       case 'ext_imagick':
    94         if ($extension != 'gif' and self::is_ext_imagick())
    95         {
    96           $this->library = 'ext_imagick';
    97           break;
    98         }
    99       case 'gd':
    100         if (self::is_gd())
    101         {
    102           $this->library = 'gd';
    103           break;
    104         }
    105       default:
    106         if ($library != 'auto')
    107         {
    108           // Requested library not available. Try another library
    109           return self::__construct($source_filepath, 'auto');
    110         }
    111         die('No image library available on your server.');
     76    if (!($this->library = self::get_library($library, $extension)))
     77    {
     78      die('No image library available on your server.');
    11279    }
    11380
     
    305272      return false;
    306273    }
    307     @exec($conf['ext_imagick_dir'].'convert', $returnarray, $returnvalue);
     274    @exec($conf['ext_imagick_dir'].'convert -version', $returnarray, $returnvalue);
    308275    if (!$returnvalue and !empty($returnarray[0]) and preg_match('/ImageMagick/i', $returnarray[0]))
    309276    {
     
    316283  {
    317284    return function_exists('gd_info');
     285  }
     286
     287  static function get_library($library=null, $extension=null)
     288  {
     289    global $conf;
     290
     291    if (is_null($library))
     292    {
     293      $library = $conf['image_library'];
     294    }
     295
     296    // Choose image library
     297    switch (strtolower($library))
     298    {
     299      case 'auto':
     300      case 'imagick':
     301        if ($extension != 'gif' and self::is_imagick())
     302        {
     303          return 'imagick';
     304        }
     305      case 'ext_imagick':
     306        if ($extension != 'gif' and self::is_ext_imagick())
     307        {
     308          return 'ext_imagick';
     309        }
     310      case 'gd':
     311        if (self::is_gd())
     312        {
     313          return 'gd';
     314        }
     315      default:
     316        if ($library != 'auto')
     317        {
     318          // Requested library not available. Try another library
     319          return self::get_library('auto');
     320        }
     321    }
     322    return false;
    318323  }
    319324
Note: See TracChangeset for help on using the changeset viewer.