2007.01.04 17:51 "[Tiff] Access to bare libtiff codecs?", by John Aldridge

2007.01.05 15:42 "Re: [Tiff] Access to bare libtiff codecs?", by Andy Cave

Hi John,

Accessing the compression routines directly is a little bit of a pain (rather a lot of pain), since they rely on quite a lot of state and the routines you want are 'hidden' (static). For example you'd need to call TIFFInitCCITTFax4 first, since all the G4 methods are declared static - so you need to create a 'dummy' (real) TIFF struct before that, and then you can if you make the 'right calls'. Even then you'd need to make sure the 'output' was preserved in your output buffer and never got flushed. Would take a little (a lot) working out and be quite fiddly.

Setting your own routines for i/o (as someone else suggested) would be even fiddlier to do I think. Since you'd capture all the TIFF header/tags as well - just as easy in this case to use a normal temporary file.

Writing a compressed TIFF file as you indicate and then reading it back is probably a lot simpler than doing either of the above.

If this is for commercial work, another alternative that might be simpler is to find someone to license you some code to write either compressed G3 or G4. In fact my company has some 'inexpensive' (depends on what you view as 'inexpensive'... :-)) commercial libraries which do exactly what you want - mail me off forum if you're interested - andy.cave@hamillroad.com. If I'm not allowed to say this, sorry everyone - I have seen other people 'advertising' their own companies related products to some degree.

Also, I'm curious - how important to you (and anyone in fact on the TIFFLib mailing list) is speed? The G3/G4 compression/decompression routines in TIFFLib are not that fast. Our libraries are significantly faster - around 2-5x faster depending on image content.



Hi, all,

We've got a requirement to create (from an array of bits) a CCITT Group 3 or 4 encoded data stream which is /not/ wrapped up in a TIFF file, and I wondered whether libtiff (which we already use for other reasons) could do this.

We could, I think, do this by creating a temporary TIFF file of the right format, calling TIFFWriteEncodedStrip to encode the data, and then calling TIFFReadRawStrip to get the encoded data back, but is there an easier way?

I've failed to find anything obvious following a quick perusal of the documentation & source code, so if this is possible I'd welcome a pointer or two to the places to look!