png
Robust, high-performance PNG and APNG decoder and encoder in pure Rust
Repository Health
Technical Analysis
png is a pure-Rust library for decoding and encoding PNG images, including animated PNG (APNG). It contains no unsafe code, is continuously fuzzed on OSS-Fuzz, and delivers performance typically on par with or better than libpng.
The crate powers the wider image-rs ecosystem and ships a fast encoding mode built on fdeflate that beats libpng’s fastest mode while producing better compression ratios. It exposes a streaming Decoder and Encoder API for reading and writing PNG data with full control over color types, bit depth, filtering, and metadata.
What You Get
- A streaming PNG Decoder that reads images incrementally
- A configurable Encoder with color type, bit depth, and filter control
- Animated PNG (APNG) decoding and encoding support
- A fast fdeflate-powered encoding mode faster than libpng
- Text and metadata chunk handling plus sRGB support
Common Use Cases
- Loading PNG images into applications and image pipelines
- Encoding rendered or processed pixel data to PNG files
- Reading and writing animated APNG sequences
- Extracting or embedding PNG text metadata and color profiles
Under The Hood
Architecture - The crate splits cleanly into a decoder module (src/decoder) that parses PNG chunks incrementally and an encoder.rs that writes them, with a filter module implementing the PNG scanline filters and adam7.rs handling interlacing. Shared code lives in chunk.rs, common.rs, and traits.rs, while text_metadata.rs and srgb.rs handle ancillary chunks. Compression is delegated to the deflate crates rather than reimplemented.
Tech Stack - Pure Rust (2021 edition, rust-version 1.73) with no unsafe code. It depends on fdeflate for fast deflate encoding, flate2 and miniz_oxide (with SIMD) for compression, crc32fast for chunk checksums, and bitflags for option handling. An optional unstable feature enables extra decode speedups on nightly.
Code Quality - The project is battle-tested and continuously fuzzed on OSS-Fuzz, with a fuzz/ harness, a png-afl target, a tests/ suite, and benches/ for performance tracking. CI runs via GitHub Actions. The absence of unsafe code plus fuzzing gives strong confidence in its robustness against malformed input.
API Design - The Decoder/Encoder API is straightforward: construct a Decoder over any Reader, obtain frame info, and read rows into a buffer; encoding mirrors this with a builder-style Encoder. docs.rs documentation and examples cover common flows, though full control over PNG’s many color types, bit depths, and filter strategies exposes the format’s inherent complexity.
Used by 4 apps in this directory
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
Fresh
Code Editors · Developer Tools
A zero-configuration terminal text editor with familiar keybindings, full mouse support, LSP-powered IDE features, and a built-in orchestrator for running multiple coding agents in parallel worktrees.
herdr
AI Agents · Developer Tools
A terminal-native agent multiplexer that runs Claude, Codex, Gemini, and other coding agents side by side in real, persistent panes you can detach from and reattach to from anywhere.
Zeron
AI Code Assistants · Developer Tools
A native, Rust-built control plane that runs and steers Claude Code, Codex, Cursor, Devin, and other coding agents from any device, locally by default with optional CRDT-synced multi-device control.