Implement a pure Rust GIF decoder in the image crate per GIF89a specification.
Requirements#
- Parse GIF header and logical screen descriptor
- Global and local color tables
- LZW decompression (variable-width codes, clear code, end-of-information code)
- Image descriptor and frame data
- Transparency via Graphic Control Extension (transparent color index)
- Multi-frame support: decode all frames with disposal methods and delay times
- Frame struct: image data, delay, disposal method
- Output first frame as RGBA8
Image, expose frame iterator for animations - API:
fn decode_gif(data: &[u8]) -> Result<Image, ImageError>(first frame)fn decode_gif_frames(data: &[u8]) -> Result<Vec<GifFrame>, ImageError>(all frames)
Acceptance Criteria#
- Decodes single-frame and animated GIFs
- Handles transparency correctly
- LZW decompressor handles code table resets and variable-width codes
- Unit tests for LZW decompression, color table parsing, frame decoding
- Integration tests with real GIF files
- No external dependencies, no
unsafe
Dependencies#
- Requires pixel format types
Phase 7 — Image Decoders