Cannot modify exif data in images

Posted on 2007-05-22 01:24:37-07 by dmadd
Cannot modify exif data in images
Hello.

I'm not very familiar with perl, or exif, but recently I've had some problems modifying the exif data contained in jpegs which were written by various Apple products, including Aperture ( more accurately the programs which I use, which were written by other people, which use this library have been having these problems).

At some point in time, Apple changed things so that Aperture now produces jpegs like:
http://www.ugcs.caltech.edu/~davinm/exiftool/bad.jpg
Opening it and saving as a jpeg in photoshop cs2 produces:
http://www.ugcs.caltech.edu/~davinm/exiftool/good.jpg

exiftool good.jpg
and
exiftool bad.jpg

both produce output which is understandably slightly different from each other. But,

exiftool -flash=fired good.jpg
works (1 image files updated) and
exiftool -flash=fired bad.jpg
fails (Error: Bad format (0) for IFD0 entry 7 - bad.jpg 0 image files updated 1 files weren't updated due to errors)

Why?
Is this because the exif bytes (45 78 69 66 ) are closer to the beginning of the file in good.jpg, and are further away in bad.jpg ?
Is this a bug in exiftool ? If so, can it be fixed ?
Is this Apple's fault (i.e. are they not following the exif spec) ? If so, what do I tell them the problem is ?


Thanks.
Direct Responses: 5198 | Write a response
Posted on 2007-05-22 11:47:22-07 by exiftool in response to 5192
Re: Apple bug (was: Cannot modify exif data in images)
This is an Apple bug. Send a bug report to them. If they get enough bug reports they may do something about it, although currently they don't plan to fix it. (See the May 21 entry in this blog for some comments about this problem.) This problem was observed using Apple Preview to write meta information, but if it also affects Aperture, it may affect all Apple products. Wow. This is big.

Here is the HtmlDump of your image. The problem is that Apple has deleted an entry from IFD0 and not properly adjusted the count of items in the IFD. In your image, the "IFD0 entries" count is 8, but in fact there are only 7 entries. This results in an 8th entry that is invalid (yellow/brown in the HtmlDump), and an invalid "next IFD" pointer (red).

This is a serious problem which will result in the loss of information in your image. And it turns out that the deleted entry is YCbCrPositioning, which is a mandatory tag according to the EXIF specification, so Apple shouldn't even be deleting this in the first place.

- Phil
Direct Responses: Write a response