/**
  * @param Thumbnail $thumbnail
  * @return void
  * @throws Exception\NoThumbnailAvailableException
  */
 public function refresh(Thumbnail $thumbnail)
 {
     try {
         $adjustments = array(new ResizeImageAdjustment(array('width' => $thumbnail->getConfigurationValue('width'), 'maximumWidth' => $thumbnail->getConfigurationValue('maximumWidth'), 'height' => $thumbnail->getConfigurationValue('height'), 'maximumHeight' => $thumbnail->getConfigurationValue('maximumHeight'), 'ratioMode' => $thumbnail->getConfigurationValue('ratioMode'), 'allowUpScaling' => $thumbnail->getConfigurationValue('allowUpScaling'))));
         $processedImageInfo = $this->imageService->processImage($thumbnail->getOriginalAsset()->getResource(), $adjustments);
         $thumbnail->setResource($processedImageInfo['resource']);
         $thumbnail->setWidth($processedImageInfo['width']);
         $thumbnail->setHeight($processedImageInfo['height']);
     } catch (\Exception $exception) {
         $message = sprintf('Unable to generate thumbnail for the given image (filename: %s, SHA1: %s)', $thumbnail->getOriginalAsset()->getResource()->getFilename(), $thumbnail->getOriginalAsset()->getResource()->getSha1());
         throw new Exception\NoThumbnailAvailableException($message, 1433109654, $exception);
     }
 }
Esempio n. 2
0
 /**
  * Refreshes this asset after the Resource has been modified
  *
  * @return void
  */
 public function refresh()
 {
     $adjustments = array(new ResizeImageAdjustment(array('maximumWidth' => $this->maximumWidth, 'maximumHeight' => $this->maximumHeight, 'ratioMode' => $this->ratioMode, 'allowUpScaling' => $this->allowUpScaling)));
     $processedImageInfo = $this->imageService->processImage($this->originalAsset->getResource(), $adjustments);
     $this->resource = $processedImageInfo['resource'];
     $this->width = $processedImageInfo['width'];
     $this->height = $processedImageInfo['height'];
 }
 /**
  * Tells the ImageService to render the resource of this ImageVariant according to the existing adjustments.
  *
  * @return void
  */
 protected function renderResource()
 {
     $processedImageInfo = $this->imageService->processImage($this->originalAsset->getResource(), $this->adjustments->toArray());
     $this->resource = $processedImageInfo['resource'];
     $this->width = $processedImageInfo['width'];
     $this->height = $processedImageInfo['height'];
     $this->persistenceManager->whiteListObject($this->resource);
 }
 /**
  * @param Thumbnail $thumbnail
  * @param Resource $resource
  * @return array
  * @throws Exception\ImageFileException
  */
 protected function resize(Thumbnail $thumbnail, Resource $resource)
 {
     $adjustments = array(new ResizeImageAdjustment(array('width' => $thumbnail->getConfigurationValue('width'), 'maximumWidth' => $thumbnail->getConfigurationValue('maximumWidth'), 'height' => $thumbnail->getConfigurationValue('height'), 'maximumHeight' => $thumbnail->getConfigurationValue('maximumHeight'), 'ratioMode' => $thumbnail->getConfigurationValue('ratioMode'), 'allowUpScaling' => $thumbnail->getConfigurationValue('allowUpScaling'))));
     return $this->imageService->processImage($resource, $adjustments);
 }