#png #decoder #png-decoder

no-std makepad-zune-png

A fast, correct and safe png decoder

2 unstable releases

0.4.10 May 11, 2025
0.2.1 Sep 20, 2023

#1408 in Images

Download history 59/week @ 2025-12-04 42/week @ 2025-12-11 50/week @ 2025-12-18 61/week @ 2025-12-25 49/week @ 2026-01-01 37/week @ 2026-01-08 64/week @ 2026-01-15 59/week @ 2026-01-22 205/week @ 2026-01-29 72/week @ 2026-02-05 33/week @ 2026-02-12 67/week @ 2026-02-19 66/week @ 2026-02-26 47/week @ 2026-03-05 63/week @ 2026-03-12 67/week @ 2026-03-19

258 downloads per month
Used in 10 crates (via makepad-widgets)

MIT OR Apache-2.0 OR Zlib

410KB
6.5K SLoC

Zune-png

A fast, correct and safe png decoder

Limitations

  • This decoder (currently) expands images with less than 8 bpp to be 8 bits(one byte) automatically. This may or may not be desired depending on your use cases.

Features

  • Fast deflate decoder
  • Vectorized filters and bit manipulation
  • Memory friendly (few allocations)
  • Zero unsafe outside of platform specific intrinsics
  • Support for animated image decoding up until the post-processing.

Usage

First, include this in your Cargo.toml

[dependencies]
zune-png = "0.2.0"

Then you can access the decoder in your library/binary.

use zune_png::PngDecoder;
// decode bytes
let decoder = PngDecoder::new(b"bytes").decode().unwrap();

Debug vs release

The decoder heavily relies on platform specific intrinsics, namely AVX2 and SSE to gain speed-ups in decoding, but they perform poorly in debug builds. To get reasonable performance even when compiling your program in debug mode, add this to your Cargo.toml:

# `zune-png` package will be always built with optimizations
[profile.dev.package.zune-png]
opt-level = 3

Benchmarks

The updated benchmarks comparing this decoder with other Rust and C decoders can be found here with the png prefix. Benchmarks are updated regularly to keep up with optimizations added.

Dependencies