From c6183b649a1f9f7a6fc4849096f5845f03c86bc0 Mon Sep 17 00:00:00 2001 From: brendan braybrook Date: Mon, 11 Aug 2014 23:21:02 +0000 Subject: wrong type returned for gif --- program/lib/Roundcube/rcube_image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php index a15368a7e..a432d9218 100644 --- a/program/lib/Roundcube/rcube_image.php +++ b/program/lib/Roundcube/rcube_image.php @@ -189,7 +189,7 @@ class rcube_image } else if($props['gd_type'] == IMAGETYPE_GIF && function_exists('imagecreatefromgif')) { $image = imagecreatefromgif($this->image_file); - $type = 'gid'; + $type = 'gif'; } else if($props['gd_type'] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')) { $image = imagecreatefrompng($this->image_file); -- cgit v1.2.3 From e2dd31f9878bb619ca53aa4708f8966808d7842a Mon Sep 17 00:00:00 2001 From: brendan braybrook Date: Mon, 11 Aug 2014 23:23:36 +0000 Subject: rotate image with GD if exit rotation data present --- program/lib/Roundcube/rcube_image.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php index a432d9218..c7a60e672 100644 --- a/program/lib/Roundcube/rcube_image.php +++ b/program/lib/Roundcube/rcube_image.php @@ -228,6 +228,24 @@ class rcube_image imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $props['width'], $props['height']); $image = $new_image; + // fix rotation of image if EXIF data exists and specifies rotation (GD strips the EXIF data) + if (file_exists($this->image_file) ) { + $exif = exif_read_data($this->image_file); + if ($exif && $exif['Orientation']) { + switch($exif['Orientation']) { + case 3: + $image = imagerotate($image, 180, 0); + break; + case 6: + $image = imagerotate($image, -90, 0); + break; + case 8: + $image = imagerotate($image, 90, 0); + break; + } + } + } + if ($props['gd_type'] == IMAGETYPE_JPEG) { $result = imagejpeg($image, $filename, 75); } -- cgit v1.2.3 From 090bacddb6e563ae3f89c9e490c6db28d96b3f95 Mon Sep 17 00:00:00 2001 From: brendan braybrook Date: Tue, 12 Aug 2014 18:39:55 +0000 Subject: changes suggested by aleks --- program/lib/Roundcube/rcube_image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php index c7a60e672..62dc5fa96 100644 --- a/program/lib/Roundcube/rcube_image.php +++ b/program/lib/Roundcube/rcube_image.php @@ -229,7 +229,7 @@ class rcube_image $image = $new_image; // fix rotation of image if EXIF data exists and specifies rotation (GD strips the EXIF data) - if (file_exists($this->image_file) ) { + if ($this->image_file && function_exists(exif_read_data) ) { $exif = exif_read_data($this->image_file); if ($exif && $exif['Orientation']) { switch($exif['Orientation']) { -- cgit v1.2.3