/**
  * @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);
     }
 }
 /**
  * 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);
 }
Пример #3
0
 /**
  * Calculates and sets the width and height of this Image asset based
  * on the given PersistentResource.
  *
  * @param PersistentResource $resource
  * @return void
  * @throws ImageFileException
  */
 protected function calculateDimensionsFromResource(PersistentResource $resource)
 {
     try {
         $imageSize = $this->imageService->getImageSize($resource);
     } catch (ImageFileException $imageFileException) {
         throw new ImageFileException(sprintf('Tried to refresh the dimensions and meta data of Image asset "%s" but the file of resource "%s" does not exist or is not a valid image.', $this->getTitle(), $resource->getSha1()), 1381141468, $imageFileException);
     }
     $this->width = is_int($imageSize['width']) ? $imageSize['width'] : null;
     $this->height = is_int($imageSize['height']) ? $imageSize['height'] : null;
 }
 /**
  * @param Thumbnail $thumbnail
  * @param PersistentResource $resource
  * @return array
  * @throws Exception\ImageFileException
  */
 protected function resize(Thumbnail $thumbnail, PersistentResource $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);
 }