Page 1 of 1

convert looses EXIF orientation info

Posted: 2009-01-25T09:46:59-07:00
by broucaries
From debian bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=512935

User uses the following script to reduce the resolution (and disk space) of
images:
#!/bin/bash
f=$1
convert -auto-orient -quality 88 -resize 1600x1200 $f $f-new
touch -r $f $f-new
ls -l $f $f-new
mv $f-new $f

What happens is "jhead" reports:
grundler <514>jhead IMG_0001.JPG
File name : IMG_0001.JPG
File size : 1584690 bytes
File date : 2009:01:25 00:29:27
Camera make : Canon
Camera model : Canon PowerShot SD850 IS
Date/Time : 2009:01:22 08:55:15
Resolution : 3264 x 2448
Orientation : rotate 90
Flash used : No
.....

After running the above convert line, I get:
grundler <516>jhead IMG_0001.JPG-NEW
File name : IMG_0001.JPG-NEW
File size : 278022 bytes
File date : 2009:01:25 00:30:53
Camera make : Canon
Camera model : Canon PowerShot SD850 IS
Date/Time : 2009:01:22 08:55:15
Resolution : 1600 x 1200
Flash used : No
....

Note orientation is NOT reported. More clear is "-v" output:
grundler <521>jhead -v IMG_0001.JPG-NEW
Exif header 9726 bytes long
Exif section in Intel order
(dir has 9 entries)
Make = "Canon"
Model = "Canon PowerShot SD850 IS"
Orientation = 0
....

The original image reports:
grundler <523>jhead -v IMG_0001.JPG
Exif header 9726 bytes long
Exif section in Intel order
(dir has 9 entries)
Make = "Canon"
Model = "Canon PowerShot SD850 IS"
Orientation = 6
XResolution = 180/1
YResolution = 180/1
ResolutionUnit = 2
DateTime = "2009:01:22 08:55:15"
....

And the image is displayed sideways (gqview won't autorotate it).

I tried without "-auto-rotate" and got the same result.

Regards

Re: convert looses EXIF orientation info

Posted: 2009-05-09T12:31:04-07:00
by broucaries
Any news ?

Bastien

Re: convert looses EXIF orientation info

Posted: 2009-05-09T17:53:09-07:00
by magick
The fastest path to a fixing a problem is to test your command against the latest version of ImageMagick to see if we already have a patch. If the problem persists we need a URL to one or two images and the command line we can use to reproduce the problem. Once we can reproduce a problem we generally have a patch within just a day or two.

Re: convert looses EXIF orientation info

Posted: 2009-05-18T22:58:46-07:00
by caramel1982
Hi magick,

I have a hosting package at 1and1.com. It's a linux box with Fedora OS. I am having some problems with the Imagemagick installation. I will try it again today and if it failed I hope that you can help me fix it. Thanks.

Simulation pret immobilier

Re: convert looses EXIF orientation info

Posted: 2009-05-21T20:35:45-07:00
by anthony
See my build method that creates RPMs specific to your OS. It was designed with fedora in mind.
http://www.imagemagick.org/Usage/api/#build

Re: convert looses EXIF orientation info

Posted: 2011-10-17T13:47:47-07:00
by ccreekin
This has been fixed, even for Canon cameras, in ImageMagick 6.5.7, if not before.

Interesting that different vendors encode Orientation EXIF differently. Canon uses "right,top" to designate the 0,0 origin, whereas Fuji encodes this as "Rotate 270 CW".

Re: convert looses EXIF orientation info

Posted: 2011-10-18T19:15:41-07:00
by anthony
broucaries wrote:From debian bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=512935

User uses the following script to reduce the resolution (and disk space) of
images:

Code: Select all

#!/bin/bash
f=$1
convert -auto-orient -quality 88 -resize 1600x1200 $f $f-new
touch -r $f $f-new
ls -l $f $f-new
mv $f-new $
f
jhead not reporting the current orientation when orientation is zero is nothing to do with ImageMagick.

More than likely what you are seeing is that the image is side ways as it's orientation says to display it sideways.
when the -auto-orient is run on the image IM rotated the image sideways permanentally, and set orientation to 0 (no orientation). as such your display program still displays it sideways, as the image now really is sideways!

Try doing -orient Top-Left instead. This should reset the incorrect orientation so your display program just displays the image 'asis' and not rotate it.

WARNING: using ImageMagick to correct JPEG meta-data is not recommended as it will cause a degradation of the image data due to the JPEG lossy compression. It only be used when you are actually modifying the image data (reszing, distorting, adding text or other info, etc). Saving to PNG is also recommended unless the result is the images FINAL file format for use on the web or elsewhere.

More importantly, preserve the original image, and always do all your image processing starting from that original through to final save.