Possible bug -auto-orient

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Possible bug -auto-orient

Post by fmw42 »

I cannot get -auto-orient to work. It seems to correct the EXIF orientation flag, but does not rotated the image to the new orientation. So it still displays incorrectly. Perhaps I am confused about what it should do or the file is corrupt in some way.

I am reporting this here in response to a question of StackOverflow at https://stackoverflow.com/questions/577 ... s=3|0.0000

I have tried numerous versions of ImageMagick and all seem to fail on my Mac OSX. It fails for IM 6.9.10.63, IM 7.0.8.63 and also 6.9.9.40, 6.9.4.0 and 6.7.8.9

Input:
http://www.fmwconcepts.com/misc_tests/M ... rg-000.jpg

Code: Select all

display MI-LANSING-240267-org-000.jpg
views rotated 180

and the verbose information shows:
exif:Orientation: 3

which means 180 deg rotation.

Code: Select all

convert MI-LANSING-240267-org-000.jpg -auto-orient MI-LANSING-240267-org-000_auto-orient.jpg
Then doing:

Code: Select all

display MI-LANSING-240267-org-000_auto-orient.jpg
is still upside down when I use

Code: Select all

display MI-LANSING-240267-org-000_auto-orient.jpg
but lists:
exif:Orientation: 1

http://www.fmwconcepts.com/misc_tests/M ... orient.jpg


I am suspicious that the file is photographed properly oriented, but has the wrong EXIF orientation flag. The thumbnail image on my desktop looks to be correctly oriented. But when I view the original full image in Mac PREVIEW or drop it onto one of several browsers, it shows up rotated wrongly.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug -auto-orient

Post by snibgo »

The linked image http://www.fmwconcepts.com/misc_tests/M ... rg-000.jpg is a photo of a house, the correct way up. But it has an incorrect orientation flag, claiming it needs to be rotated by 180 degrees.

IM's "-auto-orient" correctly rotates the image by 180 degrees, and changes the orientation flag to "normal". Of course, the result is then the wrong way up.

If we simply "-rotate 180" the linked image, and compare that to the "-auto-orient" version, the images are identical:

Code: Select all

f:\web\im>%IMG7%magick MI-LANSING-240267-org-000.jpg -auto-orient a.png

f:\web\im>%IMG7%magick MI-LANSING-240267-org-000.jpg -strip -rotate 180 r.png

f:\web\im>%IMG7%magick compare -metric RMSE a.png r.png NULL:
0 (0)
Tested with IM v7.0.7-28.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug -auto-orient

Post by fmw42 »

Yes, that is what I suspected. But I needed confirmation. How did you determine that the photo was correctly oriented?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bug -auto-orient

Post by snibgo »

ImageMagick identify -verbose, and exiftool, both say the orientation flag is "rotate 180".

I used my own image viewer that I know ignores the orientation flag. That shows the house the correct way up.

Then I used Microsoft Photo Viewer, which I know respects the orientation flag. That shows the house the wrong way up.

As an aside: the photo contains copyright text that is inverted with respect to the house.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug -auto-orient

Post by fmw42 »

Thanks, snibgo. That is what I needed to know to confirm my suspicion
Post Reply