[Gdal-dev] packbits compression no good for 16bit?

Frank Warmerdam warmerdam at pobox.com
Tue Feb 6 23:37:56 EST 2007


Matt Wilkie wrote:
> Hi GDAL,
> 
> I seem to be having a really bad stretch of gdal oddities this month :) 
> Here is the next installment:
> 
> When compressing a 22mb 16bit geotiff using packbits compression I only 
> get a 1% reduction in filesize. Is this expected? The source image is 
> 7/8ths nodata so I think I should easily get greater than 90% 
> compression. I get the same results with fwtools 1.1.4 and 1.2.0 on two 
> machines, both running WinXPsp2.
> 
>    for %a in (deflate lzw none packbits) do (
>     gdal_translate -co compress=%a source.tif compress_%a.tif
>     )
> 
>    dir *.tif
> 
>      4,810,097 source.tif
>      1,225,395 compress_deflate.tif
>      1,977,859 compress_lzw.tif
>     23,073,871 compress_none.tif
>     22,456,093 compress_packbits.tif

Matt,

I believe that packbits compression is applied byte by byte.  If your
nodata areas use a 16bit value where the high order and low order byte
are different then there will essentially be no "runs" for the packbits
compression scheme to compress.  I think you would find it does a great
deal better if your nodata value was something like 0.

Packbits is very simple minded.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list