]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix exif orientation for flipped images
authorMorris Jobke <hey@morrisjobke.de>
Sun, 18 Jan 2015 22:15:52 +0000 (23:15 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Sun, 18 Jan 2015 22:15:52 +0000 (23:15 +0100)
fixes #13363

Links:
 * http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
 * Example data: https://github.com/recurser/exif-orientation-examples

lib/private/image.php

index 07cfb0f72d349dbfb644fbb387db7992381dd802..90b024de3d3d9f484befaf483904aa16cf103178 100644 (file)
@@ -358,35 +358,42 @@ class OC_Image {
                $o = $this->getOrientation();
                $this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core'));
                $rotate = 0;
+               $flip = false;
                switch ($o) {
                        case -1:
                                return false; //Nothing to fix
                        case 1:
                                $rotate = 0;
                                break;
-                       case 2: // Not tested
+                       case 2:
                                $rotate = 0;
+                               $flip = true;
                                break;
                        case 3:
                                $rotate = 180;
                                break;
-                       case 4: // Not tested
+                       case 4:
                                $rotate = 180;
+                               $flip = true;
                                break;
-                       case 5: // Not tested
+                       case 5:
                                $rotate = 90;
+                               $flip = true;
                                break;
                        case 6:
-                               //$rotate = 90;
                                $rotate = 270;
                                break;
-                       case 7: // Not tested
+                       case 7:
                                $rotate = 270;
+                               $flip = true;
                                break;
                        case 8:
                                $rotate = 90;
                                break;
                }
+               if($flip) {
+                       imageflip($this->resource, IMG_FLIP_HORIZONTAL);
+               }
                if ($rotate) {
                        $res = imagerotate($this->resource, $rotate, 0);
                        if ($res) {