Browse Source

only rotate images that are rotated

closes #112
pull/111/merge
Aaron Parecki 5 years ago
parent
commit
79aadc4af0
No known key found for this signature in database GPG Key ID: 276C2817346D6056
  1. 8
      lib/helpers.php

8
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);

Loading…
Cancel
Save