예제 #1
0
 /**
  * Creates a thumbnail
  *
  * @return bool
  *
  * @throws \Exception
  */
 public function create()
 {
     $sourceBackend = $this->sourceFileResourceType->getBackend();
     $sourceFilePath = Path::combine($this->sourceFileResourceType->getDirectory(), $this->sourceFileDir, $this->sourceFileName);
     if ($sourceBackend->isHiddenFile($this->sourceFileName) || !$sourceBackend->has($sourceFilePath)) {
         throw new FileNotFoundException('Thumbnail::create(): Source file not found');
     }
     $image = Image::create($sourceBackend->read($sourceFilePath), $this->thumbnailRepository->isBitmapSupportEnabled());
     // Update cached info about image
     $app = $this->thumbnailRepository->getContainer();
     $app['cache']->set(Path::combine($this->sourceFileResourceType->getName(), $this->sourceFileDir, $this->sourceFileName), $image->getInfo());
     $image->resize($this->adjustedSizeInfo['width'], $this->adjustedSizeInfo['height'], $this->adjustedSizeInfo['quality']);
     $this->resizedImageData = $image->getData();
     $this->resizedImageSize = $image->getDataSize();
     $this->resizedImageMimeType = $image->getMimeType();
     unset($image);
 }