webp-rust
English | 日本語 | Overview (JA)
Pure Rust WebP decoder and partial encoder.
Status
- Still image decode:
VP8lossy,VP8Llossless - Still image encode: lossy
VP8and losslessVP8Lfrom RGBA - Alpha:
ALPHfor lossy still images and lossy animation frames - Animation: compositing to RGBA frame sequence
- Library output: RGBA only
- BMP output: example only
Library API
Top-level still-image decode:
let image = decode?;
println!;
Top-level still-image encode:
let webp = encode?;
let lossy = encode_lossy?;
let lossless = encode_lossless?;
To embed raw EXIF metadata, pass the chunk payload directly:
let webp = encode_lossless?;
Native file input:
let image = decode_file?;
Animated WebP is not accepted by decode / decode_file.
For animation, use the decoder module directly:
let animation = decode_animation_webp?;
println!;
Advanced encoder tuning stays in the encoder module:
let lossy_options = LossyEncodingOptions ;
let lossy = encode_lossy_image_to_webp_with_options_and_exif?;
let lossless_options = LosslessEncodingOptions ;
let lossless = encode_lossless_image_to_webp_with_options_and_exif?;
Current encoder scope is still-image only. The lossy path currently targets
opaque RGBA input and emits a minimal intra-only VP8 bitstream. Animated
encode is not implemented.
Examples
webp2bmp converts still WebP to a BMP file and animated WebP to a BMP sequence.
Still image:
Animation:
This writes:
target/sample_animation_0000.bmptarget/sample_animation_0001.bmp...
bmp2webp converts an uncompressed 24bpp or 32bpp BMP file to a still WebP.
Lossless:
Lossy:
This default lossy path uses -z 0 for fast encode speed.
Lossless effort also accepts -z 0..9. -z 6 is the balanced preset.
z7 is the current heavy preset, and z8..9 currently reuse that path until a
better high-effort strategy lands.
Heavier lossy search:
Tests
License
- Project code: see
LICENSE
(C) MITH@mmk 2026