[gdal-dev] changing white pixels to transparent

Frank Warmerdam warmerdam at pobox.com
Tue Feb 5 12:20:20 EST 2008


Andreas Neumann wrote:
> Hi Frank and others,
> 
> thanks for answering. I can confirm that the approach through the vrt file
> and editing the color-table works fine.
> 
> I wonder if the TIFF format really doesn't support transparency. I was
> able to save a transparent tiff file in GIMP and it loaded fine next time,
> with transparency preserved. Is this a limitation of gdal or associated
> libraries?

Andreas,

There are different approaches to transparency.  TIFF supports RGBA (32
bits per pixel) images where the alpha is transparency.  But it does not
support transparency in it's color tables for paletted images.  Nor does
it support marking one pixel value as transparent.

> When converting to PNG: how does it handle compression? I did not see any
> documentation on how to control the compression. Also, can I convert to a
> grayscale PNG from my original b/w tif? Are there any additional co
> options for the PNG format?

The PNG driver uses the default compression options from libpng.  I'm not
sure if there are any options we could expose through GDAL or not for this.

PNG supports a variety of color models through GDAL including bw (well
really greyscale), paletted, RGB and RGBA.

> Are there other formats beside PNG that support/preserve transparency?

Yes, in various ways - but relatively few that support transparency settings
in colormaps.  GIF will support a single transparent value in the colormap.

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