Standard
Industry standard behavior. Optimal balance, but may discard RGB data in Alpha=0 pixels.
Pixel Perfect
Ensures RGB integrity in Alpha=0 pixels. Critical for clean edges during scaling.
Backward Sequence
Last frame first, first frame last. Reverses the entire temporal flow.
Ping-Pong Loop
Forward then backward. Eliminates the "jump" artifact in infinite loops.
Optimized Small
Intelligent mixed-mode strategy with 50% alpha quality reduction. Best for web.
Near Lossless
Perceptual preprocessing that yielding significant bitstream compression.
Extreme Slow
Maximum exhaustive search (M6) with best predictive spatial alpha filtering.
Lossy Sharp
High-contrast preservation optimized via the Sharp YUV conversion pipeline.
Lossy Low
Absolute footprint floor for bandwidth constraints. Noticeable artifacts.
Modular Workspace & FFI Layer
The img2webp-rs architecture separates concerns into a decoupled multi-crate workspace:
- webp_anim (Library): A safe Rust abstraction over
libwebp-sys. It manages the full lifecycle of C-allocated muxer objects using Rust's RAII patterns and automated memory cleanup via theDroptrait. - img2webp (CLI Driver): A stateful command-line interface featuring a non-linear two-pass argument parser. This enables the ability to interleave frame-specific configurations (quality, duration) with sequence inputs.
Temporal Manipulation Engine
A primary enhancement in img2webp-rs is the Stateful Job Queue. Unlike standard C converters, we buffer the entire encoding plan, allowing flags like -reverse and -pingpong to manipulate the temporal sequence before the expensive encoding logic begins.
Advanced Alpha Filtering & Pipeline
Asset generation follows a rigid 4-stage deterministic pipeline:
- Safe Decoding: Imagery is decoded into raw RGBA8 buffers using audited Rust decoders (PNG, TIFF, BMP, etc.).
- Minimal Differencing: The
WebPAnimEncodercalculates the optimal sub-rectangle delta between sequential frames to minimize bitstream weight. - Pixel-Perfect Integrity: The
-exactflag preserves raw RGB data at 0% Alpha, preventing the "Dark Halo" effect common in browser rendering. - Remuxing Engine: Post-assembly metadata injection via
WebPMux.