From ca67e848eb8c8f9ca1a4d0232346dc9939788d72 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 12 May 2014 14:45:23 +0200 Subject: [PATCH] Only JPEG files (and TIFF, which we don't support) have EXIF --- lib/imagefile.php | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/imagefile.php b/lib/imagefile.php index 76231516f4..f5c30fefef 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -76,24 +76,26 @@ class ImageFile $this->width = ($info) ? $info[0]:$width; $this->height = ($info) ? $info[1]:$height; - // Orientation value to rotate thumbnails properly - $exif = exif_read_data($this->filepath); - if (isset($exif['Orientation'])) { - switch ((int)$exif['Orientation']) { - case 1: // top is top - $this->rotate = 0; - break; - case 3: // top is bottom - $this->rotate = 180; - break; - case 6: // top is right - $this->rotate = -90; - break; - case 8: // top is left - $this->rotate = 90; - break; + if ($this->type == IMAGETYPE_JPEG) { + // Orientation value to rotate thumbnails properly + $exif = exif_read_data($this->filepath); + if (is_array($exif) && isset($exif['Orientation'])) { + switch ((int)$exif['Orientation']) { + case 1: // top is top + $this->rotate = 0; + break; + case 3: // top is bottom + $this->rotate = 180; + break; + case 6: // top is right + $this->rotate = -90; + break; + case 8: // top is left + $this->rotate = 90; + break; + } + // If we ever write this back, Orientation should be set to '1' } - // If we ever write this back, Orientation should be set to '1' } }