summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2019-10-20 13:20:06 +0100
committerAaron Parecki <aaron@parecki.com>2019-10-20 13:20:06 +0100
commit79aadc4af06ec509213dd050ab986184f412ef05 (patch)
treeac0d5edb0c58ba6acd28a08a4f9d63a71d87c8d9
parent6c7a254f6b152b6dc2c68554de2bfb52d9ecdffb (diff)
only rotate images that are rotated
closes #112
-rw-r--r--lib/helpers.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index 4d6ca3c..ebe1e7b 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -438,6 +438,11 @@ function correct_photo_rotation($filename) {
if(class_exists('IMagick')) {
try {
$image = new IMagick($filename);
+
+ // Don't try to convert animated images
+ if($image->getImageIterations() == 1)
+ return;
+
$orientation = $image->getImageOrientation();
switch($orientation) {
case IMagick::ORIENTATION_BOTTOMRIGHT:
@@ -449,6 +454,9 @@ function correct_photo_rotation($filename) {
case IMagick::ORIENTATION_LEFTBOTTOM:
$image->rotateImage(new ImagickPixel('#00000000'), -90);
break;
+ default:
+ // Don't overwrite if no orientation header was returned
+ return;
}
$image->setImageOrientation(IMagick::ORIENTATION_TOPLEFT);
$image->writeImage($filename);