#png #decoder #png-decoder

no-std zune-png

A fast, correct and safe png decoder

7 unstable releases (3 breaking)

0.5.0-rc1 Apr 16, 2024
0.5.0-rc0 Apr 7, 2024
0.4.10 Jan 15, 2024
0.4.0 Nov 8, 2023
0.1.9 Mar 29, 2023

#266 in Images

Download history 232/week @ 2024-03-13 199/week @ 2024-03-20 171/week @ 2024-03-27 215/week @ 2024-04-03 281/week @ 2024-04-10 269/week @ 2024-04-17 211/week @ 2024-04-24 241/week @ 2024-05-01 276/week @ 2024-05-08 325/week @ 2024-05-15 307/week @ 2024-05-22 446/week @ 2024-05-29 574/week @ 2024-06-05 284/week @ 2024-06-12 226/week @ 2024-06-19 130/week @ 2024-06-26

1,306 downloads per month
Used in 8 crates (6 directly)

MIT OR Apache-2.0 OR Zlib

405KB
6K 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