image
image copied to clipboard
Support for WebP is imperfect: Alpha, Lossless and Animation isn't supported
Hi, all.
I noticed that the support for WebP is not all done. See https://github.com/image-rs/image/blob/702c1e7a02508eead031d4846c6ddac8e4f679be/src/codecs/webp/decoder.rs#L101
The comment below says: Alpha, Lossless and Animation isn't supported.
I dont know why not to support them and is there a plan to make them work?
I had to do
if let image::ImageFormat::WebP = fmt {
// TODO CARGO.toml throw away libwebp_image when image gets colour info in webp
Res(libwebp_image::webp_load(img.into_inner()))?
} else {
img.decode().map_err(|_| "Cannot decode image")?
}
some time back. libwebp_image was created 3 years back, so i wouldn't expect first-class webp support any time soon.
The main issue here is that image doesn't like to depend on libraries not written in Rust. Since libwebp is written in C, we rely on a (currently incomplete) re-implementation of it in Rust. The changes in https://github.com/image-rs/image/pull/1536 and https://github.com/image-rs/image/pull/1549 will be included in the next release and do improve the situation, but there is still more left.
@fintelia why does image state YES for webp support, when i still get
Cannot decode image: Unsupported(UnsupportedError { format: Exact(WebP), kind: GenericFeature("ALPH") })
?
This was fixed in https://github.com/image-rs/image/pull/1685