summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_image.php
diff options
context:
space:
mode:
authorbrendan braybrook <brendan@tucows.com>2014-08-11 23:23:36 +0000
committerAleksander Machniak <alec@alec.pl>2014-08-13 14:36:45 +0200
commit9cbdb6cd692e59d13b89af2128ab7473ce9e983f (patch)
treecbb57d8a712d5ca15aa167f78289836bdd2e6e9f /program/lib/Roundcube/rcube_image.php
parenteff2a2768dfccfd9b59a91e1350529226a359688 (diff)
rotate image with GD if exit rotation data present
Diffstat (limited to 'program/lib/Roundcube/rcube_image.php')
-rw-r--r--program/lib/Roundcube/rcube_image.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php
index dccf0e01b..9b4981c68 100644
--- a/program/lib/Roundcube/rcube_image.php
+++ b/program/lib/Roundcube/rcube_image.php
@@ -205,6 +205,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);
}