7 ms·
> It losslessy compresses images to a similar size of PNG It's worth pointing out that in cases where PNG is still the most reasonable format to use, compressi
by bscphil 5y ago
> It losslessy compresses images to a similar size of PNG
It's worth pointing out that in cases where PNG is still the most reasonable format to use, compression gains are frequently left on the table. I frequently see 20-30% additional compression with tools like ect ("efficient compression tool"), oxipng, and zopflipng, and that's starting with images that are already pretty well compressed (using the strongest settings available from traditional PNG libraries). In other words, even PNG compresses better than PNG. :-)
Case in point: I downloaded the sample images in the zip on the page and recompressed them with ect. It took only a few seconds, but 4 of the 7 sample images could be further compressed by more than 33%! After compressing them as much as I could achieve, the resulting PNG images were only 77% the size of the QOI images. Compression gains of 23% are nothing to sneeze at when it comes to lossless compression.
Of course, that's not to say that something like QOI wouldn't be useful. Even if it wasn't, I do love seeing tiny but effective implementations of algorithms like this - well done.
- amelius 5y agoSounds like you should use a compression tool that recognizes the content and recodes QOI as PNG on the fly, then zips it.
- dylan604 5y agoIf you've already encoded the content to the most effecient size, why then zip it?
- idontknowifican 5y agobecause the size of the download affects time to action
- makapuf 5y agoI would say zip is being used for tar-like functionality, but aiming Windows users.
- dylan604 5y agobut adding .zip extension doesn't make it friendly as an image format. I would never ever ever ever want to put <img src="imagename.zip"> into code any where. So if you're making a new image type that doesn't fit in a known image container, then create a new MIME type.
- wongarsu 5y agoThe 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.
- edflsafoiewq 5y agoIn the other direction, you can target a subset of PNG to get less optimized images but with QOI-like encode and decode speed: https://github.com/richgel999/fpng https://github.com/richgel999/fpng
- deleted 5y ago[deleted]
- thierryzoller 5y agoOne word: throughput
- bmn__ 5y ago> compressing them as much as I could I noticed this takes hours with ect. pngout ranks in second place with respectable results, but is fifty to hundred times faster.
- bscphil 5y agoWhat command are you using? I find `ect --strict -9` to be extremely fast, much better than oxipng or zopfli. `-9` provides the maximum compression level built in to the program; you could use the advanced options like `--allfilters-b` but I've found that this produces negligible additional compression (similar to zopfli's advanced modes) and mostly just go with `-9`. As I said in the OP, optimizing the seven test images provided by the QOI webpage took only a few seconds.
- bmn__ 5y agoYou're contradicting yourself. Either you have used `--allfilters-b --pal_sort=120 --mt-deflate=$(nproc)` and the quoted text in my previous post is true, or you haven't, and then the quote is false.
- bscphil 5y ago> compressing them as much as I could Yes, this is technically not 100% true, it's just 99.9% true. Previous tests have found those additional options to provide negligible improvement in compression. Very rarely do I get even 1% more compression out of enabling all of them compared to ect's highest built-in compression level (`-9`). Basically what I'm getting at is that ect seems to hit the point of diminishing returns much quicker than anything I've personally tested. I'm curious if you have found a tool that achieves the same or better compression more quickly, that's why I asked.