Yet another PNG library? ... Yes BUT it has more performant decoding and I learned a lot while doing it ^^. In short, it is decoding-only (not encoding), based on the nom parser (5.0.0) and miniz_oxide for inflate stuff (cf Details on different Rust implementations of deflate?)
Is it ready / published?
No, not yet, still too early, just made all stuff working together today. There are no tests, the API is barely usable, its new territory
What can it decode?
Most PNG files, except those with palettes and interlaced progressive data.
How well does it perform?
Pretty well ;). Here are some benchmark results with a bunch of images (I can provide those images but you can try with yours by replacing the path in the benchmark). Wasm tests are done with https://github.com/mpizenberg/wasm-png.
|Image||this crate||png crate||this (wasm)||png (wasm)|
|depth.png||4.2 ms||9.1 ms||12 ms||42 ms|
|eye.png||0.69 ms||0.99 ms||3 ms||8 ms|
|inkscape.png||10.1 ms||9.8 ms||19 ms||43 ms|
|rgb.png||7.4 ms||16.1 ms||17 ms||61 ms|
|screen.png||8.6 ms||10.8 ms||15 ms||43 ms|
|texture_alpha.png||0.75 ms||1.9 ms||2 ms||8 ms|
|transparent.png||22.5 ms||17.6 ms||38 ms||81 ms|
This code is generally faster than the png crate in native compilation, and always 2 to 4 times faster in wasm! This is mostly because I've put a lot of care in reducing number of allocations. The slower cases (like transparent.png) are when almost all lines are using the Paeth filter (cf implementation).
What can you do if you wish to contribute?
If you are also the kind of person excited by things getting rewritten in Rust, and interested in image processing, if you could try it and give feedback here / in GH issue would be super nice! (beware this is highly unstable API).
There is the PNG front:
- Add features such as supporting PNGs with palette, or with interlaced data, and supporting more chunk types.
- Add tests (this is not tested, I've just used some different PNG at my disposal).
- Add benchmarks.
- Documentation would be nice but might have to wait a bit for API stabilization.
There is the deflate front: (cf Details on different Rust implementations of deflate?)
- If you are the kind of person that would like to try implementing inflate with the nom parser combinator, it would fit perfectly into this crate .