brendan braybrook
2014-08-11 e2dd31f9878bb619ca53aa4708f8966808d7842a
rotate image with GD if exit rotation data present
1 files modified
18 ■■■■■ changed files
program/lib/Roundcube/rcube_image.php 18 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_image.php
@@ -228,6 +228,24 @@
                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);
                }