/** * {@inheritDoc} */ public function getCacheEntryIdentifier() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCacheEntryIdentifier', array()); return parent::getCacheEntryIdentifier(); }
/** * Get the size of a Flow Resource object that contains an image file. * * @param FlowResource $resource * @return array width and height as keys * @throws ImageFileException */ public function getImageSize(FlowResource $resource) { $cacheIdentifier = $resource->getCacheEntryIdentifier(); $imageSize = $this->imageSizeCache->get($cacheIdentifier); if ($imageSize !== false) { return $imageSize; } // TODO: Special handling for SVG should be refactored at a later point. if ($resource->getMediaType() === 'image/svg+xml') { $imageSize = ['width' => null, 'height' => null]; } else { try { $imagineImage = $this->imagineService->read($resource->getStream()); $sizeBox = $imagineImage->getSize(); $imageSize = array('width' => $sizeBox->getWidth(), 'height' => $sizeBox->getHeight()); } catch (\Exception $e) { throw new ImageFileException(sprintf('The given resource was not an image file your choosen driver can open. The original error was: %s', $e->getMessage()), 1336662898); } } $this->imageSizeCache->set($cacheIdentifier, $imageSize); return $imageSize; }