2005.01.08 02:36 "Re: [Tiff] JPEG (T.30-E, fax) in TIFF", by Joris
I'm trying to get HylaFAX capable of receiving JPEG-compressed fax images per ITU T.30 Annex E. So far so good, except that I cannot properly wrap the JPEG data into TIFF. HylaFAX uses libtiff anyway, and as faxes are often multipage, storing each page in a TIFF file is a good way to support multipage faxes. Thus, I need to get these JPEG images into a TIFF wrapper.
I like your reasoning. In fact, a more general JPEG to JPEG-in-TIFF converter might even be feasable, and useful.
Would someone kindly take a look at the URL'ed JPEG file(s)
I don't have the tools, nor sufficient knowledge of the JPEG specification, to look at the files in detail.
and explain to me which TIFF tags I need to use?
I'd say you need to make sure PhotometricInterpretation is set to 10 (PHOTOMETRIC_ITULAB), and Compression is set to 7 (COMPRESSION_JPEG). You also need to set ImageWidth and ImageLength tags, of course. You should have one single value of StripOffsets and StripByteCounts, and rows per strip needs to equal ImageLength. BitsPerSample needs to be 8 (8,8,8, to be more exact, but LibTiff should take care of that for you), SamplesPerPixel needs to be 3. IIRC, LibTiff also requires you to set the PlanarConfiguration tag to 1 (PLANARCONFIG_CONTIG), even though the spec says that's the default value and thus the tag should not be strictly requires.
Now, for the less obvious. You might need to set the Decode tag (http://www.awaresystems.be/imaging/tiff/tifftags/decode.html), depending on whether the ITULAB data in the JPEG has default range or not.
You'll also need to set the YCbCrSubSampling tag (http://www.awaresystems.be/imaging/tiff/tifftags/ycbcrsubsampling.html), since your subsampling values are not the default. Note that the tag's name incorrectly seems to imply that it is for YCbCr data only, but it should also apply in your case.
That's all I can think of.
I've tried what I've thought to be correct, but inevitably I end up getting errors with "StripOffsets" and other JPEG warnings when I pass the data through tiffcp.
Perhaps we might be able to spot a problem if you post a code snippet. Mentioning the exact errors and warnings might also ring a bell.
Note that few TIFF readers are ITULAB aware. I don't know if tiffcp can or cannot handle such a TIFF you're trying to build. In fact, it may be a challenge to find a reader that you can use to crosstest your results, and some code failing to handle your results might not be sufficient to indicate that you haven't yet succeeded perfectly fine...
Please do keep us posted on the outcome.
Are you a HylaFAX contributor? The HylaFAX links page still links to libtiff.org. Can you change that, or point me to someone who can? The correct LibTiff URL is, instead, http://www.remotesensing.org/libtiff/.
Joris Van Damme
Download your free TIFF tag viewer for windows here: