How can I make some pixels transparent?

Home > Faq > How can I make some pixels transparent?

If one wants to have pixels transparent (or semi-transparent), the following needs to be done:

  • format=image/png (note that PNGs are larger than JPGs, which might affect download speed)
  • custom script output needs to have 4 channels, fourth one being alpha, e.g. "return[1,0,0,0.5]" for semi-transparent red pixel or "return[0,0,0,0]" for full transparency
  • parameter TRANSPARENT needs to be set to FALSE not to mix two transparency processes

E.g. if one wants to have a Hollstein's cloud overview layer shown in a way, that everything except clouds is transparent, she just needs to change

let naturalColour = [B04, B03, B02].map(a => gain * a);
let CLEAR  = naturalColour;
let SHADOW = naturalColour;
let WATER  = [0.1,0.1,0.7];
let CIRRUS = [0.8,0.1,0.1];
let CLOUD  = [0.3,0.3,1.0];
let SNOW   = [1.0,0.8,0.4];

to

let naturalColour = [0,0,0,0];
let CLEAR  = naturalColour;
let SHADOW = naturalColour;
let WATER  = [0.1,0.1,0.7,1];
let CIRRUS = [0.8,0.1,0.1,1];
let CLOUD  = [0.3,0.3,1.0,1];
let SNOW   = [1.0,0.8,0.4,1];

Note that all other outputs need to be 4-channel ones as well.