[gdal-dev] '-mask' option of gdal_translate doesn't work

Peter Zhang peter at avenza.com
Tue Sep 11 07:20:25 PDT 2012


Hello,

I tried command line below that is copied from http://www.gdal.org/gdal_translate.html:

gdal_translate rgba.tif withmask.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES
It doesn’t generate transparency channel in output. But if I removed options “-b 1 –b 2 –b 3”, the output image ‘withmask.tif’ would contain transparency channel, that could be observed by opening the image in the Photoshop. But if I remove all options to modify command line like this:

gdal_translate rgba.tif withmask.tif 
The transparency channel is still generated in output even the option ‘-mask’ is not specified at all. And the last alpha channel in the source image is always picked up as transparency channel to the output no matter what band number is given to the ‘-mask’ option. Then I tried the same command line on a new RGB tiff that has more than 4 channels and output image doesn’t contains any transparency channel even ‘-mask band’ option is explicitly specified. 

It seems that the option ‘-mask’ doesn’t work and generating the transparency channel is only depends on the colorspace (RGBA or Greyscale + alpha). Please let me know how to correctly use this option.

Thanks!

Peter Z
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120911/d54cddf2/attachment.html>


More information about the gdal-dev mailing list