Last active
January 26, 2018 17:01
-
-
Save ancyrweb/06f20da3a27053002373fa939fd9d563 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* See http://sylvana.net/jpegcrop/exif_orientation.html | |
*/ | |
function fixOrientation(Imagick $image) { | |
$orientation = $image->getImageOrientation(); | |
switch($orientation) { | |
case 2: | |
$image->flipImage(); | |
break; | |
case 3: | |
$image->rotateimage("#FFF", 180); | |
break; | |
case 4: | |
$image->rotateimage("#FFF", 180); | |
$image->flipImage(); | |
break; | |
case 5: | |
$image->rotateimage("#FFF", 90); | |
$image->flipImage(); | |
break; | |
case 6: | |
$image->rotateimage("#FFF", 90); | |
break; | |
case 7: | |
$image->rotateimage("#FFF", -90); | |
$image->flipImage(); | |
break; | |
case 8: | |
$image->rotateimage("#FFF", -90); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment