convert looses EXIF orientation info

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
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

convert looses EXIF orientation info

Post 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
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: convert looses EXIF orientation info

Post by broucaries »

Any news ?

Bastien
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert looses EXIF orientation info

Post 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.
caramel1982

Re: convert looses EXIF orientation info

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert looses EXIF orientation info

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ccreekin
Posts: 5
Joined: 2010-01-01T15:44:53-07:00
Authentication code: 8675309

Re: convert looses EXIF orientation info

Post 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".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert looses EXIF orientation info

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply