image icon indicating copy to clipboard operation
image copied to clipboard

Support for WebP is imperfect: Alpha, Lossless and Animation isn't supported

Open fralonra opened this issue 4 years ago • 3 comments

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?

fralonra avatar Sep 03 '21 06:09 fralonra

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.

installgentoo avatar Oct 31 '21 05:10 installgentoo

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 avatar Oct 31 '21 15:10 fintelia

@fintelia why does image state YES for webp support, when i still get Cannot decode image: Unsupported(UnsupportedError { format: Exact(WebP), kind: GenericFeature("ALPH") }) ?

installgentoo avatar May 19 '22 15:05 installgentoo

This was fixed in https://github.com/image-rs/image/pull/1685

fintelia avatar Aug 18 '23 07:08 fintelia