image-rs / image-webp

Apache License 2.0
39 stars 7 forks source link

Decoding single channel image #108

Closed namse closed 1 day ago

namse commented 2 weeks ago

Hello, I tried to encode Luma8 without an Alpha channel losslessly, then decode it to obtain channel data equivalent to width * height bytes. However, contrary to my expectations, the decoder seems to output only in RGB or RGBA formats. Is there any way to get just a single channel as the result of decoding?

fintelia commented 2 weeks ago

This is a limitation of the webp file format. There actually isn't a way to indicate that an image is grayscale, so the behind the scenes the encoder stores Luma8 images as Rgb8.