Skip to content

Commit

Permalink
Merge branch 'next' into next-method-renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 27, 2023
2 parents 429c7dd + c05d364 commit a445ef3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Drivers/Imagick/Decoders/BinaryImageDecoder.php
Expand Up @@ -26,6 +26,24 @@ public function decode($input): ImageInterface|ColorInterface
$imagick->readImageBlob($input);
$imagick = $imagick->coalesceImages();

// fix image orientation
switch ($imagick->getImageOrientation()) {
case Imagick::ORIENTATION_BOTTOMRIGHT:
$imagick->rotateimage("#000", 180);
break;

case Imagick::ORIENTATION_RIGHTTOP:
$imagick->rotateimage("#000", 90);
break;

case Imagick::ORIENTATION_LEFTBOTTOM:
$imagick->rotateimage("#000", -90);
break;
}

// set new orientation in image
$imagick->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);

$image = new Image($imagick);
$image->setLoops($imagick->getImageIterations());
$image->setExif($this->decodeExifData($input));
Expand Down

0 comments on commit a445ef3

Please sign in to comment.