public function convertToJpg($srcFile, $desFile = "", $quality = 60)
 {
     if (empty($desFile)) {
         $desFile = str_replace(substr(strrchr($srcFile, "."), 1), "", $srcFile) . "jpg";
     }
     $img = $this->getImgWand($srcFile);
     if (MagickGetNumberImages($img) > 1) {
         MagickResetIterator($img);
         MagickNextImage($img);
         $frame = $this->getImgWand();
         MagickAddImage($frame, $img);
         DestroyMagickWand($img);
         $img = $frame;
     }
     MagickSetFormat($img, 'JPG');
     MagickSetImageCompression($img, MW_JPEGCompression);
     MagickSetImageCompressionQuality($img, $quality);
     $this->generateImg($img, $desFile);
     return $desFile;
 }
 /**
  * @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;
 }