Пример #1
0
 /**
  * Get the available Graphics Library
  * @return object Graphics Library Instance
  * @throws RuntimeException 
  */
 public static function getLib($lib = null)
 {
     if (!isset(self::$lib)) {
         if (extension_loaded('Imagick')) {
             $lib = 'Imagick';
         } else {
             if (extension_loaded('gd')) {
                 $lib = 'GD';
             } else {
                 throw new RuntimeException('No supported Image library available.');
             }
         }
         if ($lib == 'Imagick' && self::$preferImagick === false) {
             $lib = 'GD';
         }
         require_once dirname(__FILE__) . '/' . strtolower($lib) . '.php';
         $class = 'WFImage' . $lib;
         if (class_exists($class)) {
             self::$lib = new $class();
         } else {
             throw new RuntimeException('Class ' . $class . ' not found');
         }
     }
     return self::$lib;
 }