这个问题也让我发疯。我在服务器端使用PHP,因此无法使用@The Lazy Log(ruby)和@deweydb(python)解决方案。但是,它为我指明了正确的方向。我使用Imagick的getImageOrientation()将其固定在背面。
<?php
// Note: $image is an Imagick object, not a filename! See example use below.
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;
}
// 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);
}
?>
如果您想了解更多,请点击这里。http://php.net/manual/zh/imagick.getimageorientation.php