]> git.mxchange.org Git - friendica.git/commitdiff
use ImageMagick for orientation when available
authorGregory Smith <wolfy@treellama.org>
Mon, 13 Apr 2015 01:09:25 +0000 (21:09 -0400)
committerGregory Smith <wolfy@treellama.org>
Mon, 13 Apr 2015 01:09:25 +0000 (21:09 -0400)
include/Photo.php

index ccb6af29e92c22447a715e9d41c4483cd8501b99..e36fd46ca036b5e101f5d19dbf8353dfebd4a261 100644 (file)
@@ -345,6 +345,24 @@ class Photo {
     }
 
     public function orient($filename) {
+        if ($this->is_imagick()) {
+            // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
+            $orientation = $this->image->getImageOrientation();
+            switch ($orientation) {
+            case imagick::ORIENTATION_BOTTOMRIGHT:
+                $this->image->rotateimage("#000", 180);
+                break;
+            case imagick::ORIENTATION_RIGHTTOP:
+                $this->image->rotateimage("#000", 90);
+                break;
+            case imagick::ORIENTATION_LEFTBOTTOM:
+                $this->image->rotateimage("#000", -90);
+                break;
+            }
+
+            $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
+            return TRUE;
+        }
        // based off comment on http://php.net/manual/en/function.imagerotate.php
 
        if(!$this->is_valid())