Opened 17 years ago

Last modified 17 years ago

#1483 closed defect

Bug in TIFF reading (with EXIF JPEG preview) — at Initial Version

Reported by: seth@… Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.4.0
Severity: normal Keywords:
Cc:

Description

I have an error with some large (geo)tiffs that I'm working with. I've generated them with georeferenced info via the GDAL utilities, then I want to add an overview image (like a preview) using the gdaladdo utility. If I use exiftool to add a preview first, gdaladdo reports an error in the file format. See the commands below:

"
Pine06:~ sage$ cp orig.tif exif_tooled.tif
Pine06:~ sage$ cp orig.tif no_exiftool.tif
Pine06:~ sage$ ./gdaladdo -r average no_exiftool.tif 16 32
0...10...20...30...40...50...60...70...80...90...100 - done.
Pine06:~ sage$ ./exiftool '-ThumbnailImage<=thumb.jpg' exif_tooled.tif
Pine06:~ sage$ ./gdaladdo -r average exif_tooled.tif 16 32
ERROR 1: MissingRequired:exif_tooled.tif: TIFF directory is missing required "ImageLength" field
0ERROR 1: MissingRequired:exif_tooled.tif: TIFF directory is missing required "ImageLength" field
...10...20...30...40...50...60...70...80...90...100 - done.
"

At first I thought that it was a bug in exiftool, so I emailed the author. It looks like it's actually a bug with GDAL (or libtiff) expecting tags that aren't required for an EXIF image preview. Here is his full reply:

"
Unfortunately the EXIF specification defines a number of mandatory tags.  ExifTool fills in all of the ones that it can (as you can see from the output), but some it must leave to hte user.  Noteably, the ExifImageWidth and ExifImageHeight in the ExifIFD are not written automatically.  (But I have never seen an application that will complain if these are missing.)

In your case, however, ExifTool is adding IFD1, not the ExifIFD.  According to the specification, ImageWidth and ImageLength are only required in IFD1 for uncompressed images.  For compressed thumbnails (ie. JPEG), the only mandatory tags are:

- Compression
- XResolution
- YResolution
- ResolutionUnit
- ThumbnailOffset (aka JPEGInterchangeFormat)
- ThumbnailLength (aka JPEGInterchangeLength)

And these are exactly what is written.

So in this case, I think the fault is in gdaladdo, and you should send a bug report to them along with a sample image.

You can try this to see if my deduction is correct:  Write IFD1:ImageWidth and IFD1:ImageHeight to see if the gdaladdo warning disappears.  If it does, it is a gdaladdo bug.
"

I followed his recommendation with setting the height and width, and GDAL threw a new error:

"
Pine06:~ sage$ ./exiftool -v5 '-ThumbnailImage<=thumb.jpg' -IFD1:ImageWidth=512 -IFD1:ImageHeight=512 exif_tooled.tif
Pine06:~ sage$ ./gdaladdo -r average exif_tooled.tif 16 32
ERROR 1: MissingRequired:exif_tooled.tif: TIFF directory is missing required "StripOffsets" field
0ERROR 1: MissingRequired:exif_tooled.tif: TIFF directory is missing required "StripOffsets" field
...10...20...30...40...50...60...70...80...90...100 - done.
"

Change History (0)

Note: See TracTickets for help on using tickets.