From 2b256bfb9a15919ea88e93b2f347052ba1644c5a Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Mon, 26 Aug 2024 17:23:54 +0100 Subject: [PATCH] Document WebP encoder limitations --- src/codecs/webp/encoder.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/codecs/webp/encoder.rs b/src/codecs/webp/encoder.rs index 10f5803305..dfdfbead01 100644 --- a/src/codecs/webp/encoder.rs +++ b/src/codecs/webp/encoder.rs @@ -6,6 +6,23 @@ use crate::error::{EncodingError, UnsupportedError, UnsupportedErrorKind}; use crate::{ExtendedColorType, ImageEncoder, ImageError, ImageFormat, ImageResult}; /// WebP Encoder. +/// +/// ### Limitations +/// +/// Right now only **lossless** encoding is supported. +/// +/// If you need **lossy** encoding, you'll have to use `libwebp`. +/// Example code for encoding a [`DynamicImage`](crate::DynamicImage) with `libwebp` +/// via the [`webp`](https://docs.rs/webp/latest/webp/) crate can be found +/// [here](https://github.com/jaredforth/webp/blob/main/examples/convert.rs). +/// +/// ### Compression ratio +/// +/// This encoder reaches compression ratios higher than PNG at a fraction of the encoding time. +/// However, it does not reach the full potential of lossless WebP for reducing file size. +/// +/// If you need an even higher compression ratio at the cost of much slower encoding, +/// please encode the image with `libwebp` as outlined above. pub struct WebPEncoder { inner: image_webp::WebPEncoder, }