2007.04.02 12:12 "[Tiff] EXIF JPEG Thumbnail in TIFF", by Phil Harvey

2007.04.02 13:13 "Re: [Tiff] EXIF JPEG Thumbnail in TIFF", by Joris Van Damme

Phil,

An exiftool user complains that his GDAL utilities don't like the thumbnail image that I am adding with my exiftool utility. It complains that IFD1 is missing the required ImageWidth/ImageLength fields. (See http://trac.osgeo.org/gdal/ticket/1483 for the bug report.) But the EXIF specification clearly states that ImageWidth/ImageLength fields should not be included in IFD1 for a JPEG thumbnail image. (See http://www.exif.org/Exif2-2.PDF page 57.)

So my questions:

1) Does libtiff support JPEG thumbnail images in TIFF files as per the EXIF specification?

2a) If so, is there something that GDAL should be doing to avoid getting these errors from libtiff?

2b) If not, am I reading the EXIF specification correctly, and if so what library does GDAL need to use to read these images?

I'm not very familiar with the EXIF specification. However, I do feel the only authorative specification on JPEG compressed image data inside TIFF, is TIFF 6.0 specification supplement 2, http://partners.adobe.com/public/developer/en/tiff/TIFFphotoshop.pdf. As is logical, JPEG nor any other compression mode in TIFF overrides or contradicts actual TIFF basics, meaning ImageWidth and ImageLength are part of the IFD and redundant markers (JFIF markers and the like) inside the JPEG compressed data should be avoided. You can't avoid mentioning image dimensions inside the basic JPEG stream that remains, and in fact this stream's actual compressed data inherently uses these dimensions, so some minimal redundancy remains even if you properly avoid JFIF and all APP markers and such in the JPEG stream. But still, the basic fact remains that the IFD is authorative, not the compressed image data, and thus the IFD needs to mention image dimensions and if there's any contradiction of the redundant copies the logical resolution is in favour of IFD.

This is logical, and necessary. Compression mode detail is an extensible second-order thingy in TIFF. People need to be able to guess image sizes and other stuff in code that doesn't actually contain the required subcodec. That's what TIFF is all about: a uniform and simple container, that specifies image data properties, independent of compression algorithm.

So, ImageWidth and ImageLength need to be present. If your interpretation of the EXIF spec is correct in that the EXIF spec says otherwise, then that spec does not correctly build on from correct TIFF.

I'm not sure any of this is helpful for you, but it's a point worth making seeing the persistent confusion around JPEG compression in TIFF.

Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html