-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using Zstandard and/or LZ4 instead of Deflate #39
Comments
That is an interesting possibility, but would be a significant work item as it would be completely incompatible with all existing image creation and display software.
Do you have any data on that speedup, for PNG? |
The existing file format does allow for additional compression/filter methods and new ones could be added to a PNG 2.0 standard. The situation would be similar to JPEG XL where jpeg-only decoders cannot read .
There is a 'None' filter type, you're still left with an extra leading |
Brotli is also a popular choice: https://github.com/google/brotli It is worth to consider making this extension available as a new Content-Encoding similar to jxl for JPEG. So, a browser receives a recompressed file, but for a user it looks like a standard PNG. It will be required to store a bit more information to make possible restoring original PNG back (as it is done in JPEG XL for recompressed JPEG files). |
Zstandard/ZSTD looks like a better choice since it's already supported by Chrome/Firefox and it features extremely fast decompression, in fact it's faster than gzip that has been used for decades now. |
Here's a datapoint on the potential performance benefit: https://github.com/catid/Zpng |
I met with @bitbank2 who seemed interested in this (including added less powerful compression algorithms). Roping them in here. |
ZSTD officially has 22 compression levels and low presets are both faster and more powerful than Deflate. In my experience ZSTD is the most versatile compressor (not the best in terms of compression ratio of course) and almost nothing actually beats it in decompression speed which is paramount for image access. Please first make sure you've compared whatever you had in mind with ZSTD and it various compression levels. And then version 1.5.7 was released a couple of days ago and it became even faster: https://github.com/facebook/zstd/releases/tag/v1.5.7 |
PNG with any new compression algorithm will effectively be a new incompatible format. It probably should use a different name and MIME type then (e.g. PNG2 and |
We discussed this in today's meeting. That might already exist. |
If the objective is to increase decode/encode throughput at the expense of compatibility with existing decoders, than the field of candidate codecs should be broadened. Below is a throughput/compression ratio analysis across lossless image codecs: |
One of the issues we have with .PNG is slow read/write times. There are now new lossless open source codecs without patent concerns, such as Zstandard (maintained by Facebook) or LZ4:
https://facebook.github.io/zstd/
https://github.com/lz4/lz4
Zstandard is used by the new Khronos KTX2 GPU texture format specification. I propose that it be added as an option to a future version of .PNG. The possible speedups are quite significant, and for users that read and write a lot of .PNG's as part of their data processing pipelines the speedups will be high value improvements.
There are also other far simpler but even faster codecs being developed, such as .QOI's, but using this would likely require changing or not filtering the image before compression:
https://news.ycombinator.com/item?id=29328750
The text was updated successfully, but these errors were encountered: