[gdal-dev] gtiff with internal mask

Duarte Carreira DCarreira at edia.pt
Wed Jul 17 05:23:29 PDT 2013


Hi Even.

Thanks so much for your tip! It works. I did have to specify I did not want an alpha band when cutting with the shapefile:

gdalwarp -multi -wm 480 --config GDAL_CACHEMAX 256 -co photometric=ycbcr -co compress=jpeg -co alpha=no --config GDAL_TIFF_INTERNAL_MASK YES -cutline shapes\index_diss.shp vrtini.vrt testmask.tif

Seems arcgis recognizes the masked tiff, but is much much slower displaying than using a "normal" alpha band.
QGIS does need the vrt trick but then is as fast as usual.

Also, the size is must smaller when using an internal mask: from a 219MB rgba,band interleaved,jpegd image to a 27MB ycbcr,pixel interleaved,jpegd masked tiff (8x smaller). Unless I missed something...

Thanks again!
Duarte

-----Mensagem original-----
De: Even Rouault [mailto:even.rouault at mines-paris.org] 
Enviada: terça-feira, 16 de Julho de 2013 18:58
Para: gdal-dev at lists.osgeo.org
Cc: Duarte Carreira
Assunto: Re: [gdal-dev] gtiff with internal mask

Le mardi 16 juillet 2013 12:29:37, Duarte Carreira a écrit :
> I'm trying to create gtiffs with transparent areas where there are 
> voids between my original images.
> 
> I have successfully done it by using an alpha band but this process 
> created 3x larger images. I think partly because of an additional 4th 
> band and partly because I cannot use ycbcr to compress with jpeg. So I 
> thought of using internal masks expecting to get smaller images but 
> cannot get it to work.
> 
> When converting from the rgba image using -mask 4 I cannot "see" the 
> transparency and get black areas:
> 
> gdal_translate -b 1 -b 2 -b 3 -ma sk 4 --config 
> GDAL_TIFF_INTERNAL_MASK YES test_alpha.tif test_internalmask.tif
> 
> I tried looking at the images using qgis and paint.net.

I know QGIS doesn't use the GDALGetMaskBand() API, so no real surprise (that would likely be a possible QGIS enhancement). And paint.net probably doesn't support this feature of the TIFF format either.

MapServer does support mask bands however.

For QGIS, you could workaround that however. Imagine that you have a YCbCr TIFF + internal mask in.tif.

You can do : "gdal_translate -of VRT -b 1 -b 2 -b 3 -b mask in.tif out.vrt"

And QGIS should handle out.vrt as a regular RGBA dataset.

> 
> Any hints or help appreciated.
> 
> Thanks,
> Duarte
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Duarte Carreira
> Diretor | Dep. Informa??o Geogr?fica e Cartografia
> 
> www.edia.pt<http://www.edia.pt>
> www.alqueva.com.pt<http://www.alqueva.com.pt>
> Tel. +351 284315100
> 
> [http://www.edia.pt/edia/images/edia_logo2.gif]<http://www.edia.pt>

--
Geospatial professional services
http://even.rouault.free.fr/services.html



More information about the gdal-dev mailing list