2009.11.30 05:05 "[Tiff] TIFFTAG_JPEGTABLES mandatory for JPEG-in-TIFF since 3.8.x ?", by Lee Howard

2009.11.30 05:05 "[Tiff] TIFFTAG_JPEGTABLES mandatory for JPEG-in-TIFF since 3.8.x ?", by Lee Howard

Attached is a HylaFAX-received color fax... a JPEG wrapped in TIFF... libtiff used by HylaFAX was 4.0.0beta5.

(Note, attachment was too big for automated approval to the list, so I've posted it at http://www.howardsilvan.com/fax000002737.tif.)

With 3.7.4 this worked fine, but something changed between there and 3.8.2 which caused it to stop "working" as expected, and so I've procrastinated dealing with the color-fax issue since then because I was aware that the JPEG routines were being rewritten in 4.0, and I decided it best to figure out what was wrong when I got around to dealing with the matter again with libtiff v4.0.

So now that I'm working on it, things appear not much different for me than they were with 3.8.2... The JPEG inside the TIFF is fine, but when processed with the TIFF wrapper things don't work right.

Investigating this problem it appears that TIFFTAG_JPEGTABLES is being written to the TIFF file even though the application does not deliberately instruct it to be. Consequently, the JPEGTABLES tag is left as 2000 bytes of null data... which appears to confuse all TIFF viewers that I have tested... and certainly it doesn't work with the libtiff tools tiff2pdf and tiff2ps.

I've tried to prevent TIFFTAG_JPEGTABLES from being written to the TIFF with...

     TIFFSetField(tif, TIFFTAG_JPEGTABLESMODE, 0);

... but this does not seem to work as I had hoped.

Is it silly of me to not want TIFFTAG_JPEGTABLES written to the TIFF?

Is TIFFTAG_JPEGTABLES supposed to be a mandatory tag for JPEG-in-TIFF?

If I should use TIFFTAG_JPEGTABLES, then is it only expecting me to put the DHT and DQT tables - copied right from the JPEG data - into that tag? Or is there something more?

Since I need to make the application be compatible with libtiff 3.8.2 - if there's not a way to avoid writing TIFFTAG_JPEGTABLES with that version when writing JPEG-in-TIFF, then I'll probably just need to write TIFFTAG_JPEGTABLES properly... but I wanted to understand if this was intentional behavior by libtiff, or if this is a bug, or if I just don't know what I'm doing (likely).

Thanks,

Lee.