pub fn encode_lossy(
rows: PixelRows<'_>,
quality: f32,
) -> Result<Vec<u8>, EncodeError>Expand description
Encodes rows lossily at quality with the default preset, as libwebp’s
simple API does (C: WebPEncodeRGB, WebPEncodeBGR, WebPEncodeRGBA and
WebPEncodeBGRA; the X layouts take the same steps).
§Errors
EncodeError::InvalidParameter for a quality that is not finite or not
in 0 to 100, the errors of Picture::import, and the code libwebp
records.
§Examples
use webp::api::encode::{PixelLayout, PixelRows, encode_lossy};
let bgra = [30_u8, 60, 90, 255].repeat(8 * 8);
let rows = PixelRows { layout: PixelLayout::Bgra, data: &bgra, width: 8, height: 8, stride: 32 };
let webp = encode_lossy(rows, 75.0)?;
assert_eq!(&webp[12..16], b"VP8 ");