Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-f.b-one.net (mx-f.one.com [91.198.169.53])
	by mail9.b-one.net (Postfix) with ESMTP id 156EC400223
	for <info@awaresystems.be>; Thu, 27 Nov 2008 14:27:30 +0100 (CET)
X-Virus-Scanned: by one.com
X-Spam-Score: 0
X-Spam-Level: 
X-Spam-Status: No, score=0 tagged_above=0 required=6 tests=[none]
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153])
	by mx-f.b-one.net (Postfix) with ESMTP id C3D2F2800319
	for <info@awaresystems.be>; Thu, 27 Nov 2008 14:26:20 +0100 (CET)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id mARDNp5B017676;
	Thu, 27 Nov 2008 08:24:45 -0500
Received: from sasl.smtp.pobox.com (a-sasl-fastnet.sasl.smtp.pobox.com
	[207.106.133.19])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id mARDNmRl017673
	for <tiff@lists.maptools.org>; Thu, 27 Nov 2008 08:23:48 -0500
Received: from localhost.localdomain (unknown [127.0.0.1])
	by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id
	0D82B82EE3; Thu, 27 Nov 2008 08:23:48 -0500 (EST)
Received: from [192.168.2.4] (unknown [67.47.28.121]) (using TLSv1 with
	cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate
	requested)
	by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id
	8114282EE1; Thu, 27 Nov 2008 08:23:31 -0500 (EST)
Message-ID: <492E9F4C.9090805@pobox.com>
Date: Thu, 27 Nov 2008 08:23:24 -0500
From: Frank Warmerdam <warmerdam@pobox.com>
User-Agent: Thunderbird 2.0.0.6 (X11/20071022)
MIME-Version: 1.0
To: paavo@osa.pri.ee
Subject: Re: [Tiff] TIFFWriteEncodedStrip LZW compression failing for 
	certain input
References: <008dd3b0f44d72240bae5615846880ad.squirrel@194.204.58.247>
	<f5973d20da50cbe0825634b7fd960f24.squirrel@194.204.58.247>
In-Reply-To: <f5973d20da50cbe0825634b7fd960f24.squirrel@194.204.58.247>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
X-Pobox-Relay-ID: 9F98AF78-BC86-11DD-9C65-465CC92D7133-06493634!a-sasl-fastnet.pobox.com
Cc: tiff@lists.maptools.org
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

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

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
