geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
878 stars 183 forks source link

readRGB returns 3-channel data even for transparent images? #300

Open jnpatrick99 opened 2 years ago

jnpatrick99 commented 2 years ago

So readRasters returns transparent data in case of RGBA images. But readRGB always returns 3 channels right? How do I get transparency mask in that case (for example I'm reading transparent CMYK and RGB files that then project to HTML Canvas that is always RGBA). Thanks!

constantinius commented 2 years ago

Hi @jnpatrick99 As far as I understand, CMYK and RGB do not provide an alpha (transparency) channel. You have to specify an offsite color, one color that you manually render as transparent.

readRGB does read 4-channel, when the underlying chromatic representation allows for it, which is currently just RGBA.