Esempio n. 1
0
 /**
  *
  * @param string $filepath
  * @param string $styleName
  * @return string
  */
 public function process($filepath, $styleName)
 {
     $image = $this->imageFactory->create($filepath, $styleName);
     if (file_exists($image->getOutputPath())) {
         return $image->getOutputPath();
     }
     if ($this->fileSystem->checkDirectory(dirname($image->getOutputPath()))) {
         $style = $this->getStyle($styleName);
         $style->filter($image);
     }
     return $image->getOutputPath();
 }
Esempio n. 2
0
 /**
  *
  * @param string $filepath
  * @param string $styleName
  * @return \Image\Model\Image
  */
 public function create($filepath, $styleName)
 {
     $image = new Image($this->fileSystem->getUploadDir() . $filepath, $styleName);
     if ($styleName == 'original') {
         $image->setOutputPath($filepath);
         return $image;
     }
     $subdirectory = str_replace(self::PATH_DESTIATION, '', dirname($filepath));
     $destination_dir = self::PATH_IMAGE_STYLES . '/' . $styleName . '/' . $subdirectory;
     $destination = array();
     $this->fileSystem->createFilename($destination_dir, basename($filepath), $destination, true);
     $outputPath = $destination['directory'] . '/' . $destination['name'] . $destination['ext'];
     $outputPath = $this->fileSystem->getUploadDir() . strtolower($outputPath);
     $image->setOutputPath($outputPath);
     return $image;
 }