Beispiel #1
0
 /** Get image GD resource
  * @param string $path   Path to image
  * @param int    $format GD format constant
  * @return resource
  */
 public static function get_gd_resource(self $img)
 {
     $im = null;
     switch ($img->format()) {
         case 1:
             $im = imagecreatefromgif($img->get_path());
             break;
         case 2:
             $im = imagecreatefromjpeg($img->get_path());
             break;
         case 3:
             $im = imagecreatefrompng($img->get_path());
             break;
     }
     if (!is_resource($im)) {
         throw new \System\Error\File(sprintf('Failed to open image "%s". File is not readable or format "%s" is not supported.', $path, self::get_suffix($format)));
     }
     return $im;
 }