otf-pixels-codec-gif
GIF for Pixels, written from scratch
An Open Tech Foundation project
Decodes every GIF frame, interlace layout and disposal method, and encodes a single frame with a quantized palette.
[!TIP] Building an app or a server? Use
otf-pixelsinstead: it picks this codec from the file's bytes with itsgiffeature.
Use it
Transcode row by row, without holding the image:
use ;
use ;
let mut decoder = new?;
let descriptor = decoder.descriptor;
let mut encoder = new.with_colours?;
let mut out = Vecnew;
encoder.write_header?;
let mut row = vec!;
for _ in 0..descriptor.height
encoder.finish?;
Capabilities
| Area | Support |
|---|---|
| Decode | All frames, interlace, transparency, disposal; the engine sees the first frame composited |
| Encode | One frame, palette quantization to up to 256 colours |
| Checked against | libgif, both directions |
API
| Item | What it does |
|---|---|
GifDecoder, Frame |
Decoder and its frames |
GifEncoder |
Encoder; new, with_colours, from_options |
quantize, build_palette, Palette |
Colour quantization, for direct use |
GifCodec, probe |
Signature detection |
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.