2020.04.18 12:15 "[Tiff] Updating zlib library", by Vincent Ripoll

2020.04.19 05:57 "Re: [Tiff] Updating zlib library", by Paavo Helde

Speed is definitely an important factor. I have always noticed that libtiff's own LZW compression is much faster than zlib's deflate.

LZW is not very useful for 16-bit data (our main usage case). In our experience LZW often tends to increase the size of our 16-bit images, instead of compressing them.

Did you enable the predictor? It makes a world of difference in the final compression ratio. We've been using LZW with all kinds of images for a long time and have never noticed increased size.

You are right, after adding TIFFTAG_PREDICTOR=PREDICTOR_HORIZONTAL the compressed vs uncompressed ratio for our 16-bit test image went down to 0.99 instead of former 1.09. This is now indeed smaller than the original, but only by 1%, nothing to brag about (admittedly these images are pretty nasty from compressing viewpoint).

For comparison, COMPRESSION_DEFLATE in zlib FASTEST regime compressed it down to ratio 0.850 (while being 6% slower than LZW). Deflate with Z_BEST_SPEED gives ratio 0.843 and is 70% slower than LZW; deflate with Z_BEST_COMPRESSION gives ratio 0.839, but is 2.7 times slower than LZW.

When reading the image back in, LZW is consistently ca 35% slower than all the zlib/deflate variants.

So, even with the predictor, LZW does not really suit this kind of images. Admittedly such images would be best left uncompressed, but in general we do not know in advance which images compress well and which not.

Regards

Paavo