summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrendan braybrook <brendan@tucows.com>2014-08-11 23:23:36 +0000
committerbrendan braybrook <brendan@tucows.com>2014-08-11 23:23:36 +0000
commite2dd31f9878bb619ca53aa4708f8966808d7842a (patch)
tree7a5b8ecf72b80498e740c597370a0b4a5e581289
parentc6183b649a1f9f7a6fc4849096f5845f03c86bc0 (diff)
rotate image with GD if exit rotation data present
-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 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);
}