diff --git a/src/Plugin/ImageEffect/AutoOrientImageEffect.php b/src/Plugin/ImageEffect/AutoOrientImageEffect.php index a2a446e..12703be 100644 --- a/src/Plugin/ImageEffect/AutoOrientImageEffect.php +++ b/src/Plugin/ImageEffect/AutoOrientImageEffect.php @@ -148,8 +148,8 @@ class AutoOrientImageEffect extends ConfigurableImageEffectBase implements Conta // Both dimensions in input, and effect is configured to check the // the input file. Read EXIF data, and determine image orientation. $file = $this->fileMetadataManager->uri($uri); - $orientation = $file->getMetadata('exif', 'Orientation')['value']; - if (in_array($orientation, [5, 6, 7, 8])) { + $exif_orientation = $file->getMetadata('exif', 'Orientation'); + if ($exif_orientation && in_array($exif_orientation['value'], [5, 6, 7, 8])) { $tmp = $dimensions['width']; $dimensions['width'] = $dimensions['height']; $dimensions['height'] = $tmp; diff --git a/src/Plugin/ImageToolkit/Operation/gd/AutoOrient.php b/src/Plugin/ImageToolkit/Operation/gd/AutoOrient.php index c05d30d..70abab1 100644 --- a/src/Plugin/ImageToolkit/Operation/gd/AutoOrient.php +++ b/src/Plugin/ImageToolkit/Operation/gd/AutoOrient.php @@ -36,8 +36,8 @@ class AutoOrient extends GDImageToolkitOperationBase { // Read EXIF data. $file = \Drupal::service('file_metadata_manager')->uri($source_path); - $orientation = $file->getMetadata('exif', 'Orientation')['value']; - if ($orientation !== NULL) { + $exif_orientation = $file->getMetadata('exif', 'Orientation'); + if ($exif_orientation && $exif_orientation['value'] !== NULL) { // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html: // 1 = Horizontal (normal) [top-left]. // 2 = Mirror horizontal [top-right]. @@ -47,7 +47,7 @@ class AutoOrient extends GDImageToolkitOperationBase { // 6 = Rotate 90 CW [right-top]. // 7 = Mirror horizontal and rotate 90 CW [right-bottom]. // 8 = Rotate 270 CW [left-bottom]. - switch ($orientation) { + switch ($exif_orientation['value']) { case 2: return $this->getToolkit()->apply('mirror', ['x_axis' => TRUE]);