Expand description
Encodes RGB and RGBA pixel buffers as lossy WebP files.
Version 0.1.0 writes one VP8 key frame in a RIFF WebP container. It uses DC
prediction, the Y2 transform path, one token partition, and a fixed
quantizer chosen from Options::quality. The encoder keeps exact alpha
from non-opaque RGBA input in an uncompressed ALPH chunk.
The library is no_std and allocates through alloc. It reads and writes
byte slices in memory. Callers own file and stream I/O.
Options is #[non_exhaustive], so build one from its default and
assign the fields that change.
let mut opts = tiny_webp::Options::default();
opts.quality = 90;
opts.alpha = tiny_webp::Alpha::Discard;
let rgba = [128u8; 16];
let webp = tiny_webp::encode_rgba(&rgba, 2, 2, &opts)?;
assert_eq!(&webp[..4], b"RIFF");Structs§
- Options
- Settings for one encode.
Enums§
- Alpha
- What the encoder does with the alpha plane of an RGBA input.
- Error
- A call the encoder refused.
- Filter
- The loop filter strength the encoder signals in the frame header.
Constants§
- MAX_
DIMENSION - Largest width or height a WebP bitstream carries, in pixels.
Functions§
- encode_
rgb - Encodes an RGB buffer into the bytes of a WebP file.
- encode_
rgba - Encodes an RGBA buffer into the bytes of a WebP file.