示例#1
0
 /**
  * Opens an Image file
  *
  * @param $src
  * @param $errors
  * @return mixed
  */
 public static function open($src, &$errors)
 {
     $file_ext = XApp_Image_Utils::imageExtension($src);
     if (!array_key_exists($file_ext, XApp_Image_Utils::$compatibleImageTypes)) {
         $errors[] = XAPP_TEXT_FORMATTED("IMAGE_TYPE_NOT_SUPPORTED", $file_ext);
         return false;
     } else {
         $container = XApp_Image_Utils::$imageContainer;
         $container[XApp_Image_Utils::IMAGE_CONTAINER_SRC] = $src;
         $container[XApp_Image_Utils::IMAGE_CONTAINER_TYPE] = XApp_Image_Utils::$compatibleImageTypes[$file_ext];
         $img_function = "imagecreatefrom" . $container[XApp_Image_Utils::IMAGE_CONTAINER_TYPE];
         if (function_exists($img_function)) {
             $container[XApp_Image_Utils::IMAGE_CONTAINER_DATA] = $img_function($src);
             return $container;
         } else {
             $errors[] = XAPP_TEXT_FORMATTED("IMAGE_MANIPULATION_FUNCTION_NOT_FOUND", $img_function);
             return false;
         }
     }
 }
示例#2
0
 /**
  * Opens an Image file
  *
  * @param $src
  * @param $errors
  * @return mixed
  */
 public static function open($src, &$errors)
 {
     $file_ext = XApp_Image_Utils::imageExtension($src);
     if (!array_key_exists($file_ext, XApp_Image_Utils::$compatibleImageTypes)) {
         $errors[] = XAPP_TEXT_FORMATTED("IMAGE_TYPE_NOT_SUPPORTED", $file_ext);
         return false;
     }
     if (!file_exists($src)) {
         $errors[] = XAPP_TEXT_FORMATTED("FILE_DOESNT_EXISTS") . $src;
         return false;
     }
     $container = XApp_Image_Utils::$imageContainer;
     $container[XApp_Image_Utils::IMAGE_CONTAINER_SRC] = $src;
     $container[XApp_Image_Utils::IMAGE_CONTAINER_TYPE] = XApp_Image_Utils::$compatibleImageTypes[$file_ext];
     try {
         $container[XApp_Image_Utils::IMAGE_CONTAINER_DATA] = new Imagick($src);
     } catch (Exception $e) {
         $errors[] = $e->getMessage();
     }
     return $container;
 }