isAnimationGif() публичный статический Метод

Return Is Animation Gif
public static isAnimationGif ( string $path ) : boolean
$path string server local path of target image
Результат boolean
Пример #1
0
 public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume)
 {
     $opts = $this->opts;
     $volOpts = $volume->getOptionsPlugin('Watermark');
     if (is_array($volOpts)) {
         $opts = array_merge($this->opts, $volOpts);
     }
     if (!$opts['enable']) {
         return false;
     }
     $srcImgInfo = @getimagesize($src);
     if ($srcImgInfo === false) {
         return false;
     }
     // check Animation Gif
     if (elFinder::isAnimationGif($src)) {
         return false;
     }
     // check water mark image
     if (!file_exists($opts['source'])) {
         $opts['source'] = dirname(__FILE__) . "/" . $opts['source'];
     }
     if (is_readable($opts['source'])) {
         $watermarkImgInfo = @getimagesize($opts['source']);
         if (!$watermarkImgInfo) {
             return false;
         }
     } else {
         return false;
     }
     $watermark = $opts['source'];
     $marginLeft = $opts['marginRight'];
     $marginBottom = $opts['marginBottom'];
     $quality = $opts['quality'];
     $transparency = $opts['transparency'];
     // check target image type
     $imgTypes = array(IMAGETYPE_GIF => IMG_GIF, IMAGETYPE_JPEG => IMG_JPEG, IMAGETYPE_PNG => IMG_PNG, IMAGETYPE_WBMP => IMG_WBMP);
     if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) {
         return false;
     }
     // check target image size
     if ($opts['targetMinPixel'] > 0 && $opts['targetMinPixel'] > min($srcImgInfo[0], $srcImgInfo[1])) {
         return false;
     }
     $watermark_width = $watermarkImgInfo[0];
     $watermark_height = $watermarkImgInfo[1];
     $dest_x = $srcImgInfo[0] - $watermark_width - $marginLeft;
     $dest_y = $srcImgInfo[1] - $watermark_height - $marginBottom;
     if (class_exists('Imagick')) {
         return $this->watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo);
     } else {
         return $this->watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo);
     }
 }
 /**
  * Resize image
  *
  * @param  string   $hash    image file
  * @param  int      $width   new width
  * @param  int      $height  new height
  * @param  int      $x       X start poistion for crop
  * @param  int      $y       Y start poistion for crop
  * @param  string   $mode    action how to mainpulate image
  * @return array|false
  * @author Dmitry (dio) Levashov
  * @author Alexey Sukhotin
  * @author nao-pon
  * @author Troex Nevelin
  **/
 public function resize($hash, $width, $height, $x, $y, $mode = 'resize', $bg = '', $degree = 0)
 {
     if ($this->commandDisabled('resize')) {
         return $this->setError(elFinder::ERROR_PERM_DENIED);
     }
     if (($file = $this->file($hash)) == false) {
         return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
     }
     if (!$file['write'] || !$file['read']) {
         return $this->setError(elFinder::ERROR_PERM_DENIED);
     }
     $path = $this->decode($hash);
     $work_path = $this->getWorkFile($this->encoding ? $this->convEncIn($path, true) : $path);
     if (!$work_path || !is_writable($work_path)) {
         if ($work_path && $path !== $work_path && is_file($work_path)) {
             @unlink($work_path);
         }
         return $this->setError(elFinder::ERROR_PERM_DENIED);
     }
     if ($this->imgLib != 'imagick') {
         if (elFinder::isAnimationGif($work_path)) {
             return $this->setError(elFinder::ERROR_UNSUPPORT_TYPE);
         }
     }
     switch ($mode) {
         case 'propresize':
             $result = $this->imgResize($work_path, $width, $height, true, true);
             break;
         case 'crop':
             $result = $this->imgCrop($work_path, $width, $height, $x, $y);
             break;
         case 'fitsquare':
             $result = $this->imgSquareFit($work_path, $width, $height, 'center', 'middle', $bg ? $bg : $this->options['tmbBgColor']);
             break;
         case 'rotate':
             $result = $this->imgRotate($work_path, $degree, $bg ? $bg : $this->options['tmbBgColor']);
             break;
         default:
             $result = $this->imgResize($work_path, $width, $height, false, true);
             break;
     }
     $ret = false;
     if ($result) {
         $stat = $this->stat($path);
         clearstatcache();
         $fstat = stat($work_path);
         $stat['size'] = $fstat['size'];
         $stat['ts'] = $fstat['mtime'];
         if ($imgsize = @getimagesize($work_path)) {
             $stat['width'] = $imgsize[0];
             $stat['height'] = $imgsize[1];
             $stat['mime'] = $imgsize['mime'];
         }
         if ($path !== $work_path) {
             if ($fp = @fopen($work_path, 'rb')) {
                 $ret = $this->saveCE($fp, $this->dirnameCE($path), $this->basenameCE($path), $stat);
                 @fclose($fp);
             }
         } else {
             $ret = true;
         }
         if ($ret) {
             $this->rmTmb($file);
             $this->clearcache();
             $ret = $this->stat($path);
             $ret['width'] = $stat['width'];
             $ret['height'] = $stat['height'];
         }
     }
     if ($path !== $work_path) {
         is_file($work_path) && @unlink($work_path);
     }
     return $ret;
 }