示例#1
0
 protected function Error($errObj, $exit = false)
 {
     $str = "Image Creator (MagickWand) Error Message";
     $err_msg = "";
     //$err_msg .= WandGetExceptionString($errObj);
     switch (true) {
         case IsMagickWand($errObj):
             $err_msg .= MagickGetExceptionString($errObj);
             break;
         case IsDrawingWand($errObj):
             $err_msg .= DrawGetExceptionString($errObj);
             break;
         case IsPixelWand($errObj):
         case IsPixelIterator($errObj):
             $err_msg .= PixelGetExceptionString($errObj);
             break;
         default:
             $err_msg .= $errObj;
     }
     if (!empty($err_msg)) {
         $str .= "(" . $err_msg . ")";
     }
     parent::Error($str, $exit);
     return;
 }
示例#2
0
 /**
  * @return Imagens
  * @param string $digital
  * @param string $md5
  * @param boolean $high
  * @param int $active
  * @param int $total
  */
 public function createCacheJpegView($digital, $md5, $high = false)
 {
     $iImageHeightPixel = $high === false ? 960 : 2480;
     $iImageWidthPixel = $high === false ? 1280 : 3508;
     $lote = $this->generateLote($digital);
     $dirCache = sprintf('%s/cache/%s', __CAM_UPLOAD__, $lote);
     $tiff = sprintf('%s/%s/%s/%s.tif', __CAM_UPLOAD__, $lote, $digital, $md5);
     $view = sprintf('%s/%s/%s_view_%d.jpg', $dirCache, $digital, $md5, $high === false ? self::Q_LOW : self::Q_HIGH);
     $thumbs = sprintf('%s/%s/%s_thumb.jpg', $dirCache, $digital, $md5);
     if (!is_file($tiff)) {
         throw new Exception('Arquivo TIFF original não encontrado!');
     }
     if (is_file($view)) {
         return $this;
     }
     // thumbs
     if (!is_file($thumbs)) {
         MagickReadImage($magickThumbs = NewMagickWand(), $tiff);
         if (MagickGetImageWidth($magickThumbs) < MagickGetImageHeight($magickThumbs)) {
             MagickResizeImage($magickThumbs, 150, 200, MW_QuadraticFilter, 1.0);
         } else {
             MagickResizeImage($magickThumbs, 200, 150, MW_QuadraticFilter, 1.0);
         }
         MagickSetImageFormat($magickThumbs, 'JPG');
         MagickSetImageResolution($magickThumbs, 200, 200);
         MagickSetImageUnits($magickThumbs, MW_PixelsPerInchResolution);
         MagickSetImageCompression($magickThumbs, MW_JPEGCompression);
         MagickSetImageCompressionQuality($magickThumbs, 0.0);
         MagickWriteImage($magickThumbs, $thumbs);
     }
     // views
     MagickReadImage($magickView = NewMagickWand(), $tiff);
     if (MagickGetImageWidth($magickView) > MagickGetImageHeight($magickView)) {
         MagickResizeImage($magickView, $iImageWidthPixel, $iImageHeightPixel, MW_QuadraticFilter, 1.0);
     } else {
         MagickResizeImage($magickView, $iImageHeightPixel, $iImageWidthPixel, MW_QuadraticFilter, 1.0);
     }
     MagickSetImageFormat($magickView, 'JPG');
     MagickSetImageResolution($magickView, 200, 200);
     MagickSetImageUnits($magickView, MW_PixelsPerInchResolution);
     MagickSetImageCompression($magickView, MW_JPEGCompression);
     MagickSetImageCompressionQuality($magickView, 0.0);
     MagickWriteImage($magickView, $view);
     $errorMagick = MagickGetExceptionString($magickView);
     if ($errorMagick) {
         throw new Exception($errorMagick);
     }
     return $this;
 }