[gdal-dev] [GDAL-dev] convert rgba alpha layer to rgb white

Even Rouault even.rouault at mines-paris.org
Sun Feb 9 02:27:36 PST 2014


Pierre,

the issue must be "-srcnodata b4". You probably intended b4 to be understood 
as band 4, but the value expected is a numeric value so b4 is actually 
understood as 0. I've just added validation of those arguments, so that this 
doesn't get unnoticed.

You should just remove "-srcnodata b4" and try again. On a very simple 
artificial example, I get the expected result.

Note however than gdalbuildvrt has no particular handling for alpha bands, If 
you have 2 rasters that overlap partially, it will not do any blending. i.e. a  
transparent area of the raster listed in last position in the gdalbuildvrt 
command line will completely override the raster beneath. You need gdalwarp 
for better handling of transparency.

Even

> Hi list,
> 
> I’m trying to assembly some RGBA tiff in one with gdalbuildvrt and then to
> translate them to a RGB TIFF tiled file YCBCR jpeg compressed.
> 
> No problem
 But now, I would like to get a white color in the background
> instead of the black.
> 
> 
> 
> The following commands work but I get nodata (and so, black) on any white
> pixels whereas I just wanted to convert alpha to white
 The problem in on
> the vrt.
> 
> 
> 
> gdalbuildvrt assembly.vrt -srcnodata b4 –hidenodata -vrtnodata 255 *.tif
> 
> gdal_translate -of GTIFF -b 1 -b 2 -b 3 -co COMPRESS=JPEG -co
> JPEG_QUALITY=95 -co TFW=YES -co BIGTIFF=YES -co ALPHA=NO -co TILED=YES -co
> PHOTOMETRIC=YCBCR -co PROFILE=BASELINE assembly.vrt assembly_JPG.tif
> 
> gdaladdo -r gauss -ro --config COMPRESS_OVERVIEW JPEG --config
> JPEG_QUALITY_OVERVIEW 95 --config BIGTIFF_OVERVIEW YES --config
> PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config
> NODATA_VALUES 255 assembly_JPG.tif 2 4 8 16 32 64 128 256
> 
> 
> 
> Do you have an idea? The problem is the is not –init option, just
> -vrtnodata “255 255 255” to fix both background color but also the nodata
> bandper band

> 
> 
> 
> Pierre CARREAUD
> 
> Spécialiste en imagerie numérique
> 
> 
> 
> 
> carte_voeux_2014
> 
> L’INGÉNIERIE DE LA DURABILITÉ
> 
> 
> 
> SITES – Entité Île-de-France
> 
> Division du Développement Technique
> 
> 2 bis avenue du Centre
> 
> 92500 Rueil-Malmaison, France
> 
> Tel : 01 41 39 02 00 / Fax : 01 41 39 02 01
> 
>  <http://www.sites.fr/> www.sites.fr
> 
> 
> 
> CARRES  EXPERTISE  cid:image002.jpg at 01CB7A74.CDE1E680  INSTRUMENTATION /
> MESURES  cid:image002.jpg at 01CB7A74.CDE1E680  INGENIERIE

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


More information about the gdal-dev mailing list