You are here

protected function ImagemagickToolkit::parseExifData in ImageMagick 8

Parses the image file EXIF data using the PHP read_exif_data() function.

Return value

$this

1 call to ImagemagickToolkit::parseExifData()
ImagemagickToolkit::getExifOrientation in src/Plugin/ImageToolkit/ImagemagickToolkit.php
Gets the source EXIF orientation.

File

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

Class

ImagemagickToolkit
Provides ImageMagick integration toolkit for image manipulation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit

Code

protected function parseExifData() {
  $continue = TRUE;

  // Test to see if EXIF is supported by the image format.
  $mime_type = $this
    ->getMimeType();
  if (!in_array($mime_type, [
    'image/jpeg',
    'image/tiff',
  ])) {

    // Not an EXIF enabled image.
    $continue = FALSE;
  }
  $local_path = $this
    ->getSourceLocalPath();
  if ($continue && empty($local_path)) {

    // No file path available. Most likely a new image from scratch.
    $continue = FALSE;
  }
  if ($continue && !function_exists('exif_read_data')) {

    // No PHP EXIF extension enabled, return.
    $this->logger
      ->error('The PHP EXIF extension is not installed. The \'imagemagick\' toolkit is unable to automatically determine image orientation.');
    $continue = FALSE;
  }
  if ($continue && ($exif_data = @exif_read_data($this
    ->getSourceLocalPath()))) {
    $this->exifInfo = $exif_data;
    return $this;
  }
  $this
    ->setExifOrientation(NULL);
  return $this;
}