示例#1
0
 /**
  * @inheritdoc
  */
 public function generateVersion($name, $sizeName)
 {
     $file = $this->path . $name;
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (self::isImage($extension) && filesize($file) < $this->maxImageSize && $this->hasAllowedDimension($file)) {
         $versionGenerator = new ImageManipulator($file);
         $version = $versionGenerator->create($sizeName, $this->versionQuality);
         return basename($version);
     }
     return false;
 }
示例#2
0
 /**
  * @see \Rocker\Utils\FileStorage\Image\ImageModifier::create()
  * @param string $name
  * @param string $sizeName eg. 300x200 400x100
  * @return string|bool Base name of file or false if failed
  */
 function generateVersion($name, $sizeName)
 {
     $remoteFile = $this->baseURI . '/' . $name;
     $extension = pathinfo($name, PATHINFO_EXTENSION);
     if (self::isImage($extension)) {
         $tmpFile = tempnam(sys_get_temp_dir(), (string) time());
         file_put_contents($tmpFile, file_get_contents($remoteFile));
         if (filesize($tmpFile) < $this->maxImageSize && $this->hasAllowedDimension($tmpFile)) {
             $versionGenerator = new ImageManipulator($tmpFile);
             $version = $versionGenerator->create($sizeName, $this->versionQuality);
             return basename($version);
         }
     }
     return false;
 }