Here's how you can use the getImageOrientation() information to auto-rotate images to their correct orientation...
<?php
function autoRotateImage($image) {
$orientation = $image->getImageOrientation();
switch($orientation) {
case imagick::ORIENTATION_BOTTOMRIGHT:
$image->rotateimage("#000", 180); break;
case imagick::ORIENTATION_RIGHTTOP:
$image->rotateimage("#000", 90); break;
case imagick::ORIENTATION_LEFTBOTTOM:
$image->rotateimage("#000", -90); break;
}
$image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
}
?>
Example use:
<?php
$image = new Imagick('my-image-file.jpg');
autoRotateImage($image);
$image->writeImage('result-image.jpg');
?>