/** * @param Image $image * * @return ImageMetadata */ public function getImageMetadata(Image $image) { if (!$image->isHydrated()) { throw new ImageManagerException(ImageManager::ERR_NOT_HYDRATED); } if ($image instanceof ImageVariation) { throw new ImageManagerException(self::ERR_SOURCE_IMAGE); } $metadata = new ImageMetadata(); $data_inspector = new DataInspector(); $data = $image->getData(); if ($data_inspector->isPdf($data)) { $format = ImageFormat::PDF(); } else { $format = $data_inspector->getImageFormat($data); } $metadata->setMimetype($data_inspector->guessMimeType($data))->setFormat($format)->setResolution($this->getImageResolution($image))->setOrientation($this->getImageOrientation($image))->setDimensions($this->getImageDimensions($image)); return $metadata; }
/** * Mark a file as existing on the remote. * If metadata object is populated, that metadata will be stored * against the image tag stored in the cache layer. * * @param string $key * @param ImageMetadata|null $metadata * * @return $this */ protected function tag($key, ImageMetadata $metadata = null) { if (!$this->cache_pool) { return null; } $item = $this->cache_pool->getItem('remote.' . $key); if (null !== $metadata) { $value = $metadata->serialise(); } else { $value = 1; } $item->set($value, null); return $this; }