BUG: convert 6.5 -resize looses EXIF tag XResolution

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
maxlo

BUG: convert 6.5 -resize looses EXIF tag XResolution

Post by maxlo »

When using convert 6.5 to resize images (jpg produces by a Canon 450D), I have noticed that the resulting image does not have the property Exif.Image.XResolution anymore. Instead, there is an entry Exif.Image.0x0001.
convert 6.4 works OK.
There are some programs that get confused with this, and can not read any EXIF data. For instance, picasa.

Some more details:

Version that works OK:
ImageMagick 6.4.5 2009-06-04 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC

This is from Ubuntu 9.04

Versions that do NOT work:
Version: ImageMagick 6.5.4-10 2009-10-04 Q16 OpenMP http://www.imagemagick.org
Version: ImageMagick 6.5.2.9 (I don't have the rest of the line -- sorry)

These versions are from Gentoo x86

Command executed:
convert -resize 1000^ <input.jpg> <output.jpg>

EXIF diff:
I used exiv2 -pt on both output images. The `diff -u' is:
--- exif64 2009-10-04 17:58:14.262363951 +0200
+++ exif65 2009-10-04 17:58:19.743373129 +0200
@@ -1,7 +1,7 @@
Exif.Image.Make Ascii 6 Canon
Exif.Image.Model Ascii 15 Canon EOS 450D
Exif.Image.Orientation Short 1 top, left
-Exif.Image.XResolution Rational 1 72
+Exif.Image.0x0001 0x0000 1 160
Exif.Image.YResolution Rational 1 72
Exif.Image.ResolutionUnit Short 1 inch
Exif.Image.DateTime Ascii 20 2009:10:04 17:01:24


Original test image, image resized with convert 6.4 and image resized with convert 6.5:

http://picasaweb.google.com/maxicombina ... 9O67NbdswE#

Image names indicate the image type (original, resized with 6.4, resized with 6.5)

Regards
Maxi

PS: as an end note, I would like to note that the image size obtained with 6.5 is ~30% bigger than the one obtained with 6.4, with the exact same command line.

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

Re: BUG: convert 6.5 -resize looses EXIF tag XResolution

Post by magick »

We can reproduce the problem you reported and have a patch. The problem was not the resolution but the orientation EXIF tag. Thanks.

maxlo

Re: BUG: convert 6.5 -resize looses EXIF tag XResolution

Post by maxlo »

magick wrote:We can reproduce the problem you reported and have a patch. The problem was not the resolution but the orientation EXIF tag. Thanks.
It is great to hear that, thanks!! I am looking forward to see this patch in gentoo, I really use convert a *lot* :)
(if you could also post a patch that applies to version 6.5.4.10, that would be awesome!)

I really would appreciate if you can clarify a couple of things, though :)
1) Why do the diff shows a difference in XResolution? Note that XResolution was effectively gone (I used gqview and exiv2 to analyze the EXIF data)
2) In the resulting image the Orientation tag is OK: top, left. You can check this in the files I uploaded to picasa...
3) The resulting image size.

Thanks again, kind regards
Maxi

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

Re: BUG: convert 6.5 -resize looses EXIF tag XResolution

Post by magick »

In magick/profile.c/SyncImageProfiles(), remove
  • (void) WriteProfileLong(endian,1UL,p+4);
from case 0x0112. The orientation tag was improperly overwriting the next tag which happened to be the X resolution tag. We suspect its a copy / paste bug.

Add -quality 75 to your command line to reduce the size of the resulting JPEG image.

maxlo

Re: BUG: convert 6.5 -resize looses EXIF tag XResolution

Post by maxlo »

Thanks again. I will try this patch (today at evening probably) and let you know :)
This is why I love open source!

Maxi

maxlo

Re: BUG: convert 6.5 -resize looses EXIF tag XResolution

Post by maxlo »

magick wrote:In magick/profile.c/SyncImageProfiles(), remove
  • (void) WriteProfileLong(endian,1UL,p+4);
from case 0x0112. The orientation tag was improperly overwriting the next tag which happened to be the X resolution tag. We suspect its a copy / paste bug.
The patch works OK, thanks. I have also noticed that version 6.5.6-8 works OK.
Add -quality 75 to your command line to reduce the size of the resulting JPEG image.
I know aobut this, thanks :)
I guess I was not clear enough in my question... I wanted to know why the difference in size in version 6.5 and 6.4. Do they have different defaults for the quality parameter? Or is it something else? (some internal engine magick)

Kind regards, great work
Maxi

Post Reply