diff --git a/exif_orientation.module b/exif_orientation.module index 51882bc..db15909 100644 --- a/exif_orientation.module +++ b/exif_orientation.module @@ -70,8 +70,15 @@ function exif_orientation_file_presave($file) { * @link: http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/ */ function _exif_orientation_rotate($file) { - if (function_exists('exif_read_data') && $file->filemime == 'image/jpeg') { - $file_exif = @exif_read_data(drupal_realpath($file->uri)); + $mime_types = ['image/jpeg', 'image/png']; + if (function_exists('exif_read_data') && in_array($file->filemime, $mime_types)) { + $realPath = \Drupal::service('file_system')->realpath($file->getFileUri()); + + if ($realPath === FALSE) { + return; + } + + $file_exif = exif_read_data($realPath); // Ensure that the Orientation key|value exists, otherwise leave. if (!is_array($file_exif) || !isset($file_exif['Orientation'])) {