UprootLabs / poly-flif

:camera: A poly-fill for the FLIF image format.
https://uprootlabs.github.io/poly-flif/
Other
244 stars 11 forks source link

Grayscale images are causing trouble #26

Closed jonsneyers closed 7 years ago

jonsneyers commented 7 years ago

I think it's because your code assumes the image either has 3 channels (RGB) or 4 (RGBA), but there's also a possibility that it has just 1 channel (grayscale). When attempting to decode grayscale images, things go wrong because you're trying to access non-existent channels.

For grayscale images, you can just set R=G=B=[channel 0 value].

hrj commented 7 years ago

Thanks @jonsneyers for reporting. Fixed and added a sample grayscale image to the demo.