image-png icon indicating copy to clipboard operation
image-png copied to clipboard

[Feature Request] Enabling uncompressed PNG support

Open BlueSwordM opened this issue 1 year ago • 3 comments

Currently, image provides support for many PNG compression levels, all the way from Fast, Best, Huffman, and RLE.

However, according to the PNG specification, it is possible to store only uncompressed deflate blocks.

While this would be a niche feature addition, it would be very useful for scenarios where the highest encoding speed is required, as the encoding speed of uncompressed PNGs is obviously the highest among all other settings, and unlike PPM, we get greater compatibility with general software with it.

It shouldn't be too hard to add it to image's PNG implementation, so hopefully it won't take too much time to do so.

Summary of feature request: Enabling/Implementing uncompressed PNG support for maximum encoding/decoding speed.

Example program of something that would heavily benefit from this: https://github.com/shssoichiro/butter-video

BlueSwordM avatar Aug 02 '22 23:08 BlueSwordM

Migrating to image-png because this is exactly the kind of feature that our format-specific crates are suited to handle...

Looking into this, it seems that the blocker is that the deflate crate doesn't current support this feature. However, flate2 does support it, and there is interest in switching over to using it (because deflate is in maintenance mode).

fintelia avatar Aug 03 '22 02:08 fintelia

Oh, I completely forgot there are multiple format specific crates. Thanks for the tip.

And yeah, a PR to enable flate2 utilization replacing the current deflate crate seems like a good idea.

BlueSwordM avatar Aug 03 '22 04:08 BlueSwordM

We've now switched to fdeflate for fast compression, which does support writing uncompressed data. At the moment that's only used as a fallback if normal fast compression isn't able to shrink the data. But I'd be open to accepting a PR exposing it as a user facing feature if it turns out to be significantly faster than our existing "Fast" compression

fintelia avatar Oct 15 '23 05:10 fintelia