Last active
October 8, 2020 00:26
-
-
Save bobmagicii/d151a0f1a8876c63a5e7d5ccc33f4423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Image = new Imagick($Filename); | |
$Orientation = $Image->GetImageOrientation(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Image = new Imagick($Filename); | |
$Orientation = $Image->GetImageOrientation(); | |
if($Orientation === Imagick::ORIENTATION_RIGHTTOP) { | |
$Image->RotateImage('#000000',-90); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Image = new Imagick($Filename); | |
$Orientation = $Image->GetImageOrientation(); | |
if($Orientation === Imagick::ORIENTATION_TOPRIGHT) { | |
$Image->FlopImage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Image = new Imagick($Filename); | |
$Flop = FALSE; | |
$Rotate = 0; | |
// determine the orientation of the image. | |
switch($Image->GetImageOrientation()) { | |
case Imagick::ORIENTATION_TOPLEFT: | |
$Rotate = 0; | |
break; | |
case Imagick::ORIENTATION_RIGHTTOP: | |
$Rotate = -90; | |
break; | |
case Imagick::ORIENTATION_BOTTOMRIGHT: | |
$Rotate = 180; | |
break; | |
case Imagick::ORIENTATION_LEFTBOTTOM: | |
$Rotate = 90; | |
break; | |
case Imagick::ORIENTATION_TOPRIGHT: | |
$Flop = TRUE; | |
$Rotate = 0; | |
break; | |
case Imagick::ORIENTATION_RIGHTBOTTOM: | |
$Flop = TRUE; | |
$Rotate = -90; | |
break; | |
case Imagick::ORIENTATION_BOTTOMLEFT: | |
$Flop = TRUE; | |
$Rotate = 180; | |
break; | |
case Imagick::ORIENTATION_LEFTTOP: | |
$Flop = TRUE; | |
$Rotate = 90; | |
break; | |
} | |
// handle any rotation needed. | |
if($Rotate !== 0) | |
$Image->RotateImage('#000000',$Rotate); | |
// mirror image if needed. | |
if($Flop === TRUE) | |
$Image->FlopImage(); | |
// then force a normal orientation and overwrite. | |
$Image->SetImageOrientation(Imagick::ORIENTATION_TOPLEFT); | |
$Image->WriteImage($Filename); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
switch($Image->GetImageOrientation()) { | |
case Imagick::ORIENTATION_TOPRIGHT: | |
$Flop = TRUE; | |
case Imagick::ORIENTATION_TOPLEFT: | |
$Rotate = 0; | |
break; | |
case Imagick::ORIENTATION_RIGHTBOTTOM: | |
$Flop = TRUE; | |
case Imagick::ORIENTATION_RIGHTTOP: | |
$Rotate = -90; | |
break; | |
case Imagick::ORIENTATION_BOTTOMLEFT: | |
$Flop = TRUE; | |
case Imagick::ORIENTATION_BOTTOMRIGHT: | |
$Rotate = 180; | |
break; | |
case Imagick::ORIENTATION_LEFTTOP: | |
$Flop = TRUE; | |
case Imagick::ORIENTATION_LEFTBOTTOM: | |
$Rotate = 90; | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment