/**
  * @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;
 }
Example #2
0
 /**
  * Set image data.
  *
  * @param string $data
  *
  * @return $this
  */
 public function setData($data)
 {
     $this->data = $data;
     $this->persistent = false;
     // Guess MIME-type
     $inspector = new DataInspector();
     $this->raw_content_type = $inspector->guessMimeType($this->data);
     return $this;
 }