/** * @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); } }
/** * 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); }
/** * Calculates and sets the width and height of this Image asset based * on the given Resource. * * @param FlowResource $resource * @return void * @throws \TYPO3\Media\Exception\ImageFileException */ protected function calculateDimensionsFromResource(FlowResource $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 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); }