AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
November 2008

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2008.11.26 15:15 "TIFFWriteEncodedStrip LZW compression failing for certain input", by <paavo@osa.pri.ee>
2008.11.26 15:53 "Re: TIFFWriteEncodedStrip LZW compression failing for certain input", by Frank Warmerdam
2008.11.27 10:49 "Re: TIFFWriteEncodedStrip LZW compression failing for certain input", by <paavo@osa.pri.ee>
2008.11.27 13:23 "Re: TIFFWriteEncodedStrip LZW compression failing for certain input", by Frank Warmerdam

2008.11.27 13:23 "Re: TIFFWriteEncodedStrip LZW compression failing for certain input", by Frank Warmerdam

paavo@osa.pri.ee wrote:
>> In short, my problem is that TIFFWriteEncodedStrip in LZW mode is
>> producing corrupt output for some image content.
> 
> I have found out it was my mistake. I read the strip back in by
> TIFFReadRawStrip(), but did call the wrong function to determine the
> initial buffer size (TIFFStripSize() instead of TIFFRawStripSize()). Thus,
> if the compressed data was larger than the original, I failed to capture
> the extra bytes.
> 
> The question remains why the image is not compressable by LZW, is it some
> fundamental problem with the algorithm? For example, gzip is able to
> compress the uncompressed TIFF file with the same image 128 times!

Paavo,

You may want to set TIFFTAG_PREDICTOR to PREDICTOR_HORIZONTAL.  This
changes the pixel values to be compressed to deltas from the previous pixel
and may make your image much more compressible.  It is generally a good idea
for image data.

Note that gzip does not use LZW, it uses Deflate (also available in many
builds of libtiff).  It is also possible that differencing is automatically
applied by gzip - I'm not that familiar with the details of how these things
work.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent