From fb9abfef06b13628d01d17b0c995ec9f6859b8b0 Mon Sep 17 00:00:00 2001 From: t-prod Date: Wed, 15 Apr 2015 10:59:48 +0200 Subject: [PATCH] Error in generating images if the orientation is not returned --- timthumb.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/timthumb.php b/timthumb.php index db43bb6..19611e6 100644 --- a/timthumb.php +++ b/timthumb.php @@ -551,16 +551,18 @@ protected function processImageAndWriteToCache($localImage){ if($auto_rotate && preg_match('/^image\/(?:jpg|jpeg)$/i', $mimeType)){ $exif = exif_read_data($localImage); $ort = $exif['Orientation']; - switch($ort) { - case 3: // 180 rotate left - $image = imagerotate($image, 180, -1); - break; - case 6: // 90 rotate right - $image = imagerotate($image, -90, -1); - break; - case 8: // 90 rotate left - $image = imagerotate($image, 90, -1); - break; + if(!empty($ort)){ + switch($ort) { + case 3: // 180 rotate left + $image = imagerotate($image, 180, -1); + break; + case 6: // 90 rotate right + $image = imagerotate($image, -90, -1); + break; + case 8: // 90 rotate left + $image = imagerotate($image, 90, -1); + break; + } } }