public processImage ( |
||
$originalResource | ||
$adjustments | array | |
Résultat | array | resource, width, height as keys |
/** * @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); }
/** * @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); }