Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 3
0
 /**
  * Check if we support this data-type.
  *
  * @param string $data
  *
  * @return bool
  */
 public function supports(&$data)
 {
     $inspector = new DataInspector();
     return $inspector->getImageFormat($data) !== null;
 }
Exemplo n.º 4
0
 /**
  * Check the data data for the image type.
  *
  * If unknown or no data data is present, null will be returned
  *
  * @deprecated since 1.1.0 Use DataInspector::getImageFormat() instead
  *
  * @return ImageFormat|null
  */
 public function getDataFormat()
 {
     $inspector = new DataInspector();
     return $inspector->getImageFormat($this->data);
 }