Esempio n. 1
0
 /**
  * Resize an image using the computed settings.
  *
  * @param FileInterface  $file
  * @param StyleInterface $style
  *
  * @return string
  */
 public function resize(FileInterface $file, StyleInterface $style)
 {
     $filePath = $this->randomFilePath($file->getFilename());
     list($width, $height, $option) = $this->parseStyleDimensions($style);
     $method = 'resize' . ucfirst($option);
     if ($method == 'resizeCustom') {
         $this->resizeCustom($file, $style->dimensions)->save($filePath, $style->convertOptions);
         return $filePath;
     }
     $image = $this->imagine->open($file->getRealPath());
     if ($style->autoOrient) {
         $image = $this->autoOrient($file->getRealPath(), $image);
     }
     $this->{$method}($image, $width, $height)->save($filePath, $style->convertOptions);
     return $filePath;
 }
Esempio n. 2
0
 /**
  * Process the queuedForWrite que.
  */
 protected function flushWrites()
 {
     foreach ($this->queuedForWrite as $style) {
         if ($style->dimensions && $this->uploadedFile->isImage()) {
             $file = $this->resizer->resize($this->uploadedFile, $style);
         } else {
             $file = $this->uploadedFile->getRealPath();
         }
         $filePath = $this->path($style->name);
         $this->move($file, $filePath);
     }
     $this->queuedForWrite = [];
 }