You are here

public function ImagemagickToolkit::getExifOrientation in ImageMagick 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/ImagemagickToolkit.php \Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::getExifOrientation()
  2. 8 src/Plugin/ImageToolkit/ImagemagickToolkit.php \Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::getExifOrientation()

Gets the source EXIF orientation.

Return value

int The source EXIF orientation.

File

src/Plugin/ImageToolkit/ImagemagickToolkit.php, line 747

Class

ImagemagickToolkit
Provides ImageMagick integration toolkit for image manipulation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit

Code

public function getExifOrientation() {
  if ($this->exifOrientation === static::EXIF_ORIENTATION_NOT_FETCHED) {
    if ($this
      ->getSource() !== NULL) {
      $file_md = $this->fileMetadataManager
        ->uri($this
        ->getSource());
      if ($file_md
        ->getLocalTempPath() === NULL) {
        $file_md
          ->setLocalTempPath($this
          ->ensureSourceLocalPath());
      }
      $orientation = $file_md
        ->getMetadata('exif', 'Orientation');
      $this
        ->setExifOrientation(isset($orientation['value']) ? $orientation['value'] : NULL);
    }
    else {
      $this
        ->setExifOrientation(NULL);
    }
  }
  return $this->exifOrientation;
}