diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-08-13 14:32:41 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-08-13 14:32:41 +0200 |
commit | 9275671174027db104936e050941e79ffcb9b3e7 (patch) | |
tree | aea46d8745aa6d1597d5914ef0f8d5993610c6b7 /program | |
parent | 30f240478a0755001626be02965400303d722935 (diff) | |
parent | 090bacddb6e563ae3f89c9e490c6db28d96b3f95 (diff) |
Merge pull request #211 from bbraybrook/gd_rotate_thumb
Fix incorrect thumbnail rotation with GD and exif orientation data (#1490029)
Diffstat (limited to 'program')
-rw-r--r-- | program/lib/Roundcube/rcube_image.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php index a15368a7e..62dc5fa96 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); @@ -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 ($this->image_file && function_exists(exif_read_data) ) { + $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); } |