Hi everybody,
I'm new to this forum, but I've done some research with PNG and 7-Zip compression
First, let me clarify some prejudices:
1. PNG does not always compress higher than a 7-Zip-compressed BMP. 7-Zip does compress many images 25% better (nothing to do with alpha, meta data, etc), even if you compare it to a PNG that has been optimized with OptiPNG, PNGOut and DeflOpt. However, on some images, 7-Zip performs just horrible (due to the loss of pre-compression filters and the wrong compression method).
2. LZMA is not the optimal compression method for images. Yes, it is often better than Deflate (5-30 %). However, PPMd is even better (again 5-15%) than LZMA. If LZMA compresses a BMP better than PPMd does, the result is usually bigger than a PNG (because the row filtering is the real deal then).
3. The time argument is just wrong. Optimizing a PNG with OptiPNG, PNGOut and DeflOpt (for highest compression) takes like ten times longer than writing and compressing a BMP with PPMd and still, the result is often larger. Hey, we are talking about the highest possible compression here … no one expects it to complete in a split second!
Also, JPEG on highest settings is still far from lossless (especially regarding color information). There is a special Lossless JPEG codec, but from what I've heard, it's mostly unsupported and its efficiency is somewhere around PNG's. I would be interested in reading some facts on that, though.
My idea:
If a PNG is smaller than a PPMd/LZMA-compressed BMP, this is only because of PNG's row filtering. If, on the other hand, a PPMd/LZMA-compressed BMP is smaller than a PNG, this is only because of the superior compression method. So, can't we combine the advantages of both?
Yes, we can We can save an image as a PNG (so the image data is pre-filtered) but without compression and then compress the whole file with PPMd (which then operates on uncompressed, pre-filtered data). Such images are always smaller than a PNG (15 - 50 % smaller than a PNG on highest compression level, 10 - 35 % smaller than a PNG optimized with OptiPNG, PNGOut and DeflOpt). They are also always smaller than BMPs compressed with 7-Zip (0.5 to 60 %).
The whole process is slow, but still not as slow as optimizing a PNG to the max. It yields to higher compression. It consumes a lot of memory, but PNG optimization does, too.
The most time-consuming problem here is finding the best filters … brute-force, it's comparable to the run-time of OptiPNG -o7.
Since only one image at a time is compressed, one could save some of the 7z archive features (multi-file and directory handling, file names, modification date etc) and call the whole thing ".7png".
I have no experience or any particular interest in developing a plugin. However, everybody who regards this opportunity to compress images to the max should consider these discoveries. I have also made some benchmarks, if anyone is interested.