Example #1
0
 /**
  * Sets the image type (in lowercase letters), the image height and width.
  *
  * @return mixed TRUE or PEAR_error
  * @access protected
  * @see PHP_Compat::image_type_to_mime_type()
  * @link http://php.net/getimagesize
  */
 static function _get_image_details($image)
 {
     $data = @getimagesize($image);
     //  1 = GIF,   2 = JPG,  3 = PNG,  4 = SWF,  5 = PSD,  6 = BMP,
     //  7 = TIFF (intel byte order),   8 = TIFF (motorola byte order),
     //  9 = JPC,  10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF,
     // 15 = WBMP, 16 = XBM
     if (!is_array($data)) {
         return PEAR::raiseError("Cannot fetch image or images details.", true);
     }
     switch ($data[2]) {
         case IMAGETYPE_GIF:
             $type = 'gif';
             break;
         case IMAGETYPE_JPEG:
             $type = 'jpeg';
             break;
         case IMAGETYPE_PNG:
             $type = 'png';
             break;
         case IMAGETYPE_SWF:
             $type = 'swf';
             break;
         case IMAGETYPE_PSD:
             $type = 'psd';
             break;
         case IMAGETYPE_BMP:
             $type = 'bmp';
             break;
         case IMAGETYPE_TIFF_II:
         case IMAGETYPE_TIFF_MM:
             $type = 'tiff';
             break;
         case IMAGETYPE_JPC:
             $type = 'jpc';
             break;
         case IMAGETYPE_JP2:
             $type = 'jp2';
             break;
         case IMAGETYPE_JPX:
             $type = 'jpx';
             break;
         case IMAGETYPE_JB2:
             $type = 'jb2';
             break;
         case IMAGETYPE_SWC:
             $type = 'swc';
             break;
         case IMAGETYPE_IFF:
             $type = 'iff';
             break;
         case IMAGETYPE_WBMP:
             $type = 'wbmp';
             break;
         case IMAGETYPE_XBM:
             $type = 'xbm';
             break;
         default:
             return PEAR::raiseError("Cannot recognize image format", IMAGE_TRANSFORM_ERROR_UNSUPPORTED);
     }
     self::$img_x = self::$new_x = $data[0];
     self::$img_y = self::$new_y = $data[1];
     self::$type = $type;
     return true;
 }