From ce821d0891d9fa17716e8987218c81eb79a96003 Mon Sep 17 00:00:00 2001 From: Gregory Smith Date: Sun, 12 Apr 2015 21:09:25 -0400 Subject: [PATCH] use ImageMagick for orientation when available --- include/Photo.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/Photo.php b/include/Photo.php index ccb6af29e..e36fd46ca 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -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())