Page 1 of 1

convert -auto-orient not working for some images...

Posted: 2009-08-29T15:54:09-07:00
by jeff_ayars
I've got an image from a Canon PowerShot SD790 IS that doesn't work with convert -auto-orient but I'm not sure if it's a bug or user head alignment error. I'm running 6.5.3-7 on Mac OS X.

I'm testing with two images: problem.jpg and works.jpg. problem is the one that causes the problem and works, well, works.

http://www.pelago.com/media/2009/08/problem.jpg
http://www.pelago.com/media/2009/08/works.jpg

using identify -format '%[exif:orientation]' I get:
6 for problem.jpg
8 for works.jpg

I run convert <image> -auto-orient auto-<image> to rotate them and produce auto-problem.jpg and auto-works.jpg

http://www.pelago.com/media/2009/08/auto-problem.jpg
http://www.pelago.com/media/2009/08/auto-works.jpg

using identify -format '%[exif:orientatin]' I get:
1 for auto-problem.jpg
1 for auto-works.jpg

Going deeper and using identify -verbose <image> | grep 'Orientation' I get:
auto-problem.jpg:
Orientation: TopLeft
exif:Orientation: 1
tiff:Orientation: 6

auto-works.jpg:
Orientation: TopLeft
exif:Orientation: 1

I'm wondering if there's a problem with -auto-orient if there's orientation in the XMP. Same results all around if I add '-strip' to the convert command.

Any suggestions? Should I file a bug?

JEff

Re: convert -auto-orient not working for some images...

Posted: 2009-08-29T16:28:11-07:00
by jeff_ayars
Found another image that has the same problem, from an iPhone this time:

http://www.pelago.com/media/2009/08/problem_2.jpg

identify -verbose problem_2.jpg | grep 'Orientation'
Orientation: RightTop
exif:Orientation: 6

convert problem_2.jpg -auto-orient auto-problem_2.jpg

http://www.pelago.com/media/2009/08/auto-problem_2.jpg

identify -verbose auto-problem_2.jpg | grep 'Orientation'
Orientation: TopLeft
exif:Orientation: 1

Still confused...

Re: convert -auto-orient not working for some images...

Posted: 2009-08-29T23:10:25-07:00
by jeff_ayars
Started looking at the one image that I had that was working vs the ones I had that weren't. It appears there's a problem with images with orientation 6 (RightTop). Orientations 3 (BottomRight) and 8 (LeftBottom) -auto-orient just fine.

So, thoughts on what might be wrong with RightTop orientation?

Re: convert -auto-orient not working for some images...

Posted: 2009-08-30T23:59:34-07:00
by anthony
First if you are just loading -- auto-orient and saving. DON'T!!!!

JPEG images are a lossy file format, reading and saving them degrades the image.
The -auto-orient is provided for image process such as generating thumbnails and proof sheets, or general image processing where you are doing a lot more than just rotating the image.

If you want to just auto-orient and save the image again the better way is to use a specialised tool to do the task, such as "jhead" This does not read or decode the JPEG image data, just tells the file format to rotate the data without actually modifying the data. This will NOT degrade the image data.


Now... as for your problem...
I downloaded 'problem.jpg'
If I just display that image it looks right way up. so it does not need auto-orient.

Code: Select all

convert problem.jpg show:
however if I run -auto-orient the image is displayed sideways...

Code: Select all

convert problem.jpg -auto-orient show:
Even jhead will incorrectly rotate the image using its -autorot flag

Code: Select all

   jhead -autorot problem.jpg
   display problem.jpg
Actually even JHEAD finds other problems!!!
Nonfatal Error : 'problem.jpg' Illegally sized exif makernote subdir (6656 entries)

Looks like the image has already been rotated, but the auto-orient flag has NOT been cleared!
jhead can clear this using -norot

IM can do this too using -orient top-left BUT this is NOT recommended for the same reasons as above.

No problem found in IM, only in the image itself!


The same fault is in your second exampe image "problem_2.jpg" but without the EXIF error.
The image has already been rotated but the orientation flag has NOT been cleared to indicate that it has been rotated.

Again no problem found in IM. Only in the image itself!