[gdal-dev] Color-palette file for use in rgb2pct
Frank Warmerdam
warmerdam at pobox.com
Mon Feb 1 06:37:47 EST 2010
Luuk Schaminee wrote:
> Hi,
>
> I am trying to convert a 24 bit RGB TIFF file to a 8 bit TIFF file. Without the –pct option this works perfectly but I want to control the created colors with a palette file. So I tried the following command:
> rgb2pct -pct c:\color_file.txt c:\image.tif e:\new_image.tif.
...
> So now my question. What format must the palette file be in? and can you give me a working example.
Luuk,
The palette must be in a GDAL supported raster file format (ie. TIFF,
PNG, GIF, etc). Likely the easiest format for you to prepare manually
would be VRT format. The following VRT is one with a small color table
and no actual raster data:
<VRTDataset rasterXSize="226" rasterYSize="271">
<Metadata/>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Palette</ColorInterp>
<ColorTable>
<Entry c1="238" c2="238" c3="238" c4="255"/>
<Entry c1="237" c2="237" c3="237" c4="255"/>
<Entry c1="236" c2="236" c3="236" c4="255"/>
<Entry c1="229" c2="229" c3="229" c4="255"/>
</ColorTable>
</VRTRasterBand>
</VRTDataset>
The c1/c2/c3/c4 entries are the red, green, blue and alpha components
of color entries. You can have up to 256 entries in a normal file.
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 | Geospatial Programmer for Rent
More information about the gdal-dev
mailing list