Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#3547 closed enhancement (fixed)

GTiff: support writing color map in two band byte (256 colour + alpha) images

Reported by: maphew Owned by: Even Rouault
Priority: normal Milestone: 1.8.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

Global Mapper can write 256 colour geotiff's with an alpha channel. Gdal_translate reads these okay but drops the colour map on conversion:

0Warning 1: Unable to export color table to GeoTIFF file.  Color tables
can only be written to 1 band Byte or UInt16 GeoTIFF files.

Attachments (3)

gm_cmap+alpha.tif (551.9 KB) - added by maphew 10 years ago.
Global Mapper 2 band byte file with colour map and alpha channel
gm_cmap+alpha.gdalinfo.txt (7.4 KB) - added by maphew 10 years ago.
gdalinfo report on GM 2 band byte file with colour map and alpha
gdal_outfile.tif (666.2 KB) - added by maphew 10 years ago.
gdal_translate -co compress=lzw "gm_cmap+alpha.tif" gdal_outfile.tif

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by maphew

Attachment: gm_cmap+alpha.tif added

Global Mapper 2 band byte file with colour map and alpha channel

Changed 10 years ago by maphew

Attachment: gm_cmap+alpha.gdalinfo.txt added

gdalinfo report on GM 2 band byte file with colour map and alpha

Changed 10 years ago by maphew

Attachment: gdal_outfile.tif added

gdal_translate -co compress=lzw "gm_cmap+alpha.tif" gdal_outfile.tif

comment:1 Changed 10 years ago by Even Rouault

Owner: changed from warmerdam to Even Rouault

comment:2 Changed 10 years ago by Even Rouault

Component: UtilitiesGDAL_Raster
Milestone: 1.8.0
Resolution: fixed
Status: newclosed
Summary: support color map in two band byte (256 colour + alpha) imagesGTiff: support writing color map in two band byte (256 colour + alpha) images

Fixed in trunk (r19517) and tested in r19518. I've also fixed gdal_translate -expand rgba on such datasets : it crashed previously. Now it takes the 3 components of the color table for R,G,B and copy the alpha channel of the source to the target.

I'd note this is a very unusual formulation of TIFF. I found this discussion on the libtiff mailing list - http://www.asmail.be/msg0055391721.html - where this is acknowledged. There's no technical obstacle to implement it with libtiff, but you should expect interoperability issues with many readers not ready for it. As you noted, GlobalMapper? 11 supports it (but previous versions not). I've found that gimp could also read correctly such images (but cannot save them : 'TIFF save cannot handle indexed images with alpha channel.'). Most software will ignore the alpha band, such as OpenEV, the display utility from ImageMagick?, Eye of Gnome, .... Latest version of QGis in osgeo4w is confused and displays the image with weird colors (it looks correct when only the 1st band is present)

comment:3 Changed 10 years ago by maphew

wow, that was fast! and thorough too; I appreciate the high level overview of what other programs would do with such imagery. thanks :)

comment:4 Changed 10 years ago by maphew

...and for anyone not running the development leading edge, I realized one can keep the colour map by dropping the second band, or vice versa:

gdal_translate "gm_cmap+alpha.tif" out.tif -b 1
gdal_translate "gm_cmap+alpha.tif" out-alpha.tif -b 2
Note: See TracTickets for help on using tickets.