[Gdal-dev] Color table

Frank Warmerdam warmerdam at pobox.com
Sun Oct 29 11:17:43 EST 2006


Ivan Lucena wrote:
> If you are translating *to* geotiff with color table it will always have
> 256. I guess hat is how TIF was designed.
> 
> -----Original Message-----
> From: gdal-dev-bounces at lists.maptools.org
> [mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Patti Giuseppe
> Sent: Friday, October 27, 2006 6:00 AM
> To: gdal-dev at lists.maptools.org
> Subject: [Gdal-dev] Color table
> 
> I'm trying to understand hoe to keep the colortable during a 
> gdal_translate operation.
> I'm translating a geotiff with Colortabel=RGB with 2 entries and i get 
> Colortable=RGB with 256 entries. The problem is that the file size 
> increases a lot during conversion, because it adds so many entries not 
> needed (because the source is a raster with white=0 and black=1)

Ivan / Patti,

Somehow I seem to have missed the original message.

The GDAL GeoTIFF writer currently does not support writing 1bit per pixel
images.  The smallest data type it supports writing is 8bit.  So 1bit
(bitonal) images will come out of a translation as 8bit images.  If you don't
use any compression these will be quite a bit larger. If you apply a
decent compression technique (eg. DEFLATE/ZIP or LZW) the result shouldn't
be too much larger, or might even be a lot smaller if the source was not
compressed.

The color table size in TIFF is always dependent on the sample size.  So
8bit images will always have 256 color entries even if 254 of them are
unused, as in your case.

The GDAL GeoTIFF driver may implement support for 1/2/4 bit images in
the future, though it hasn't been a priority for me in the past.

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