\n".
"HAPedit 3.1.11.111 (juillet 2019 17:09:54)********************";
$image = new Imagick('Img_3.jpg');
//$image->rotateimage("#000", 180); // rotate 180 degrees
autoRotateImage($image);
echo($orientation = $image->getImageOrientation()."****");
// - Do other stuff to the image here -
$image->writeImage('result-image.jpg');
function autoRotateImage($image) {
$orientation = $image->getImageOrientation();
switch($orientation) {
case imagick::ORIENTATION_BOTTOMRIGHT:
$image->rotateimage("#000", 180); // rotate 180 degrees
break;
case imagick::ORIENTATION_RIGHTTOP:
$image->rotateimage("#000", 90); // rotate 90 degrees CW
break;
case imagick::ORIENTATION_LEFTBOTTOM:
$image->rotateimage("#000", -90); // rotate 90 degrees CCW
break;
}
$image->rotateimage("#000", 180);
// Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image!
$image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
}
?>