2004.07.21 05:28 "[Tiff] JPEG Compression Support", by Jean Paul Mir V.

2004.07.22 19:47 "Re: [Tiff] JPEG Compression Support", by Andrey Kiselev

Hi, Jean,

I'm working on a C++ ATL component for TIFF conversion to PCL, PS And PDF. Actually I have completed TiffToPCL and TiffToPS translation based on tiff2ps and tifftopcl tools of libtiff.

Hmm, I don't remember the tifftopcl tool in libtiff, but probably you can contribute something to our library? ;-)

Everything works fine until I started using Grayscale and Color Images using JPEG compression. After many errors I successfully created libtiff.lib, but when I tried to convert the file using my ATL I got so many errors regarding unrecognized tags and so on. One of those alerts saids "Old-Style JPEG Support is not installed"... then I enabled OJPEG compression and recompile it again.

You (or your customers) are using so called 'Old-style JPEG compression'. It is partially supported by libtiff, by you should not rely on that support.

At this time I got an error like "..._ jpeg_reset_huff_decode unrecognized... " or something like that...

I searched on internet and found an article saying that I would need to patch libtiff to add OJPEG support to the library.. I could not patch the library but I found the missing function:

GLOBAL(void)
 jpeg_reset_huff_decode (register j_decompress_ptr cinfo)
 { register huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy;
   register int ci = 0;


   /* Discard encoded input bits, up to the next Byte boundary */
   entropy->bitstate.bits_left &= ~7;
   /* Re-initialize DC predictions to 0 */
   do entropy->saved.last_dc_val[ci] = 0; while (++ci < cinfo->comps_in_scan);
 }

I just copy-paste it into jduff.c and then the compilation ends up successfully.

You don't need to search internet, because all instructions are in the contrib/ojpeg directory of the libtiff package. There is a patch which should be applied to libjpeg sources.

Once I got the library and my DLL compiled(after Library compilation), I tried to convert a JPEG Compressed tiff file to a PCL file and all I got is a full of gray lines page.

Could someone tell me how could I build propertly the library with support for JPEG and OJPEG compression???

Unfortunately the 'old-style' JPEG compression is not supported by the upstream libtiff developers. You have the two choices:

  1. Dig into the problem yourself (and contribute the patches back to us ;-)
  2. Force your users to drop out their software producing old style JPEGs and switch them to the latest TIFF standard.

Of course, you may send the problematic files to us, but it is no guarantees that the problem will be fixed shortly, sorry.

Andrey

Andrey V. Kiselev
Home phone: +7 812 5274898 ICQ# 26871517