3 ms·
The PNG format basically boils down to "encode pixel values as the difference to previous pixels to make it more compressible, compress with deflate, add metada
by wongarsu 5y ago
The PNG format basically boils down to "encode pixel values as the difference to previous pixels to make it more compressible, compress with deflate, add metadata". Zipping it won't improve on that.
If you're willing to break compatibility anyways you could however improve PNG by substituting a better compression algorithm like zstd or lzma.
- antisthenes 5y agoZStd really seems like it should be the standard compression algorithm going forward from 2020.
- adgjlsfhk1 5y agoLZ4 is definitely worth using in some situations, but as far as I can tell, the two of them pretty much define the Pareto frontier.
- bscphil 5y agoThis is not true at all. PNG uses the DEFLATE algorithm which is a perfectly general algorithm for compressing data, it's not just a matter of encoding pixel differences. That's the real reason it doesn't make sense to zip a PNG - the internal data in the image is literally already zipped (the zip format uses DEFLATE). You are however correct that zstd would be a better algorithm than DEFLATE to be the basis of a modern image format - however, that sort of misses the point as well because there are modern techniques for encoding images losslessly that are much better than general data compression can achieve. JPEG-XL has a lossless mode that is "about 35% smaller than PNG" according to their website. That's almost certainly more than you would get out of switching to zstd, or even LZMA.
- bscphil 5y agoI apologize to wongarsu - I'm mildly dyslexic, and I missed the part of their comment where they mentioned that PNG uses DEFLATE, and leaving out that part totally changes the meaning of the comment. Their comment makes total sense after I happened to reread it.