/** * 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; }
/** * 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 = []; }