otf-pixels-codec-webp
WebP for Pixels, lossy and lossless, written from scratch
An Open Tech Foundation project
Decodes and encodes both WebP bitstreams, VP8 lossy and VP8L lossless, with alpha. Opening reads only the header; pixels decode on the first row.
[!TIP] Building an app or a server? Use
otf-pixelsinstead: it picks this codec from the file's bytes with itswebpfeature.
Use it
Transcode row by row, without holding the image:
use ;
use ;
use EncodeOptions;
let mut decoder = new?;
let descriptor = decoder.descriptor;
let mut encoder = from_options;
let mut out = Vecnew;
encoder.write_header?;
let mut row = vec!;
for _ in 0..descriptor.height
encoder.finish?;
Capabilities
| Area | Support |
|---|---|
| Decode | Lossy, lossless, alpha; an animation's first frame |
| Encode | Lossy at a quality (default), or lossless |
| Checked against | libwebp: decodes match exactly, and libwebp reads back every file written |
API
| Item | What it does |
|---|---|
WebPDecoder |
Decoder |
WebPEncoder |
Encoder; new, from_options (quality, lossless) |
WebPCodec, probe |
Signature detection |
vp8l |
The lossless bitstream, for direct use |
Part of Pixels
| Crate | Role |
|---|---|
otf-pixels |
The chainable Image API most users want |
otf-pixels-core |
Graph, tiles, scheduler, codec and op traits |
otf-pixels-ops |
Image operations |
otf-pixels-compress |
DEFLATE, zlib, LZW, checksums |
otf-pixels-codec-* |
One crate per format |
License
Apache-2.0 — see LICENSE.