Problems with commenting of jpeg files

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
habilis

Problems with commenting of jpeg files

Post by habilis »

I have a problem with commenting jpeg files in ImageMagick version 6.5.1-0 2009-03-30 Q16 on Windows XP.

In Windows you can add a comment to jpg files by right-clicking the file, selecting Properties, and editing a number of fields under the Summary tab, including comments. This comment field has the advantage that Windows Explorer can be configured to display it.

a) When I use convert -comment, the comment does get put into the file (I can see it with a binary editor), but it's not where Windows can find and use it. This is perhaps not a bug, but is annoying.

b) If I use -resize or -comment when converting a file, any existing Windows comment gets clobbered - it's as if ImageMagick doesn't know about the comment format being used by Windows.

c) Worse, after doing either -resize or -comment, the Windows commenting procedure no longer works on the output file (it lets you go through the whole commenting process, apparently successfully, but when you're done, Windows still doesn't see any comment on the file). It's as if ImageMagick has created some slightly non-standard jpeg file that Windows is not 100% compatible with. There's no problem with the input file; Windows can add a comment to that.

Problems b) and c) are not consistent; they occur with some images, but not others, and I can't determine why. They occur with my digital camera images and professionally scanned images I have of some old slides, but not with some other scanned images I have.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Problems with commenting of jpeg files

Post by magick »

Sounds like more of a bug in Windows than ImageMagick. JPEG images are embedded in the JFIF image format and they have a very specific marker for comments (i.e. JPEG_COM). Windows may choose to ignore this marker and instead extract a comment for an EXIF, XMP, or IPTC profile. We're not sure. ImageMagick follows all published standards, where as Microsoft and Adobe tend to ignore standards and do things in a proprietary way (i.e. IE 6, the morphing Microsoft Word format, etc.). If you post a reference on how Microsoft extracts and embeds comments in JPEG image files we will investigate further.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Problems with commenting of jpeg files

Post by el_supremo »

FYI: I filled in the summary fields of a jpg on my Win XP system and then did a verbose identify of the file.

Code: Select all

Properties:
    create-date: 2009-04-13T11:35:29-06:00
    exif:WinXP-Author: 104, 0, 105, 0, 109, 0, 115, 0, 101, 0, 108, 0, 102, 0, 0, 0
    exif:WinXP-Comments: 99, 0, 111, 0, 109, 0, 109, 0, 101, 0, 110, 0, 116, 0, 0, 0
    exif:WinXP-Keywords: 107, 0, 101, 0, 121, 0, 119, 0, 111, 0, 114, 0, 100, 0, 0, 0
    exif:WinXP-Subject: 119, 0, 104, 0, 97, 0, 116, 0, 101, 0, 118, 0, 101, 0, 114, 0, 0, 0
    exif:WinXP-Title: 70, 0, 97, 0, 110, 0, 99, 0, 121, 0, 32, 0, 116, 0, 105, 0, 116, 0, 108, 0, 101, 0, 0, 0
Then I resized the file and the exif info is still there. PSPX also shows it..

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
habilis

Re: Problems with commenting of jpeg files

Post by habilis »

I have an example input file here, which has a Windows comment of "This is a test comment":

http://finch.customer.netspace.net.au/TestInput.jpg

Running the command "convert TestInput.jpg -resize 50% TestOutput.jpg" produces this output:

http://finch.customer.netspace.net.au/TestOutput.jpg

Windows comments are stored as exif:WinXP-Comments. According to identify -verbose, the windows comment is still in TestOutput.jpg, but Windows doesn't display it, nor does it allow me to edit it through right-click/Properties/Summary. I can do those things in TestInput.jpg, so convert has done something to the file that stops Windows being able to see or modify the comment.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Problems with commenting of jpeg files

Post by el_supremo »

I don't know why but the difference appears to be that those which fail already had an EXIF header in the file.
That is, if the file doesn't have an EXIF header, adding a Win XP comment and resizing the file will result in one which can still be read by WinXP.
If the file already has an EXIF header (e.g. from a Nikon, as in the provided examples, or Canon camera in my test), adding a WinXP comment and then resizing the image results in a file which WinXP can't read. However, PSPX can still read the whole EXIF header including the WinXP comment. So WinXP is being picky about something.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Post Reply