2005.01.07 20:18 "[Tiff] JPEG (T.30-E, fax) in TIFF", by Lee Howard
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've sent a color fax from a Brother MFC-3100C (to HylaFAX) and had the image data dumped to a file (rather than to TIFFWriteRawData as it would usually do). Here is the raw, unchanged result:
As I suspect is common with JPEG faxes, the SOF marker at byte 570 doesn't indicate the image length (it's set at zero). However, the DNL marker at the end of the file indicates an image length of 2128 lines. Most image viewers, including libjpeg do not support this ("DNL not supported"). So, if you fix the SOF marker to include image length, then most image viewers should be able to handle the image. I've done this. With a hex editor I changed the image length portion of the SOF marker to 2128 (changing two bytes from 0x00, 0x00 to 0x08, 0x50) to produce this version that should show up in most image viewers...
Okay, so far so good. Now we have JPEG image data that can be viewed. Now I need to properly wrap it into the TIFF file. This is where I have problems, and I'm hoping that some kind soul here could help out.
I don't immediately know how to analyze the JPEG image to determine the parameters, but following T.30-E it looks like the image should be:
4:1:1 Chrominance subsampling
CIE Standard Illuminant D50
Default gamut range
200 x 200 dpi
However, the full range of possible JPEG types are discussed in T.4 Annex E, and it may not be as I expect. What I'm having trouble determining, though, is what information from the JPEG markers is actually needed by libtiff in the TIFF tags, and which TIFF tags need to be used to express that information.
Would someone kindly take a look at the URL'ed JPEG file(s) and explain to me which TIFF tags I need to use? 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.