Ejemplo n.º 1
0
 /**
  * Check if we support this data-type.
  *
  * @param string $data
  *
  * @return bool
  */
 public function supports(&$data)
 {
     $inspector = new DataInspector();
     // Normal image formats supported
     if ($inspector->getImageFormat($data) !== null) {
         return true;
     }
     // PDF supported
     if ($inspector->isPdf($data)) {
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }