17 comments

[ 2.8 ms ] story [ 33.9 ms ] thread
> Typically, other archives like .tar.bz2 can be smaller. But those aren’t backwards-compatible!

Is there any point for (new) .bz2 archives in the era of Zstd?

While not very popular, ECT [1] is (still?) the best solution in this space and has been my go-to tool for this purpose.

[1] https://github.com/fhanau/Efficient-Compression-Tool

I had no heard of ECT, but I'm not impressed. I've just benchmarked it against two others PNG optimizers, and here are the file sizes for default and max levels:

    1985457 oxipng-o6.png
    2030036 oxipng-o2.png
    2125459 ect-o9.png
    2144598 ect-o3.png
    2169351 optipng-o7.png
    2215086 optipng-o2.png
    2218326 original.png

    oxipng 9.1.5
    OptiPNG version 7.9.1
    Efficient Compression Tool Version 0.9.5
BTW, I could not compile ECT on my Linux system, because its CMake config was too old. I used the Windows release through Wine, but it shouldn't change the results above.

I tried to apply ECT to a few .gz files, but it complained it was not compatible, and I did not dig further.

[edited for a typo s/I/it/]

Good to know that oxipng has surpassed ECT; there is a reason why i put "(still?)" in my original comment. How quick is it? (The main selling point of ECT was that it was way faster than OptiPNG etc. while results being smaller.)
APKs need to be zipaligned, I don't see that mentioned.
Nice, interesting to see if it helps docx much.
I know you meant well but...

"It deletes empty folders" and "Let me know if this is a problem for you"

NEVER DO THAT. I know you meant well, but the first rule of any program is to NEVER automatically delete something without informing the user. NEVER. Users keep empty folders for structure, reminders, or placeholders because software will dump files into it later when it's run. If it was there when they zipped it up, it should be there when they unzip it. Otherwise they'll check the before and after and it will show some folders missing, create confusion, and the user will run off trying to find out if anything else is missing.

Example: A user zips up a program. Some programs are coded to look for a folder and dump files into it, if the folder is missing the program will fail. I've had that occasionally over the years. Not all programs will recreate a missing folder.

> This has the side effect of removing empty directories

yeah, this will inevitably break things. excluding those from the directory stripping shouldn't be too hard (TM)

Do any formats using ZIP as the underlying format use ZIP comments for metadata? Unless there's a lot of compressors leaving "Zip file generated by MySuperZipper™" then I imagine any comments left were probably done for a good reason.
Obviously, the purpose of this tool isn't to preserve 100% compatibility. Things like removing empty directories makes that clear.

But, why would you remove comments? Presumably, if those are there, they were added for a specific reason. And the author acknowledges the space savings are minimal.

You can also make ZIP files smaller by switching the compression from Deflate to Zstandard. In the one case I tried this, this resulted in a 60% file size decrease [1]. Unfortunately Info-ZIP which provides the unzip command hasn't had a release in 18 years, so it doesn't support this newer compression/decompression method. You have to use 7-Zip instead.

[1] https://github.com/UKGovernmentBEIS/inspect_ai/pull/3145

Ken Silverman (of Build Engine fame) has written a few deflate-centric compression utilities[0]. The PNGOUT recompressor is the most famous of these (and is very good – it practically always beats OptiPNG), but the suite also includes a .zip archive recompressor called KZIP. I'd be curious to see how ZIP Shrinker compares to this tool.

[0]: https://advsys.net/ken/utils.htm

so this tool: - Strips away comments, metadata and directories(!!) - re-compresses the data with deflate (on presumably higher setting)

makes me feel uneasy that sth. which does lossy compression(metadata is lost) is called "ZIP Shrinker". Hope nobody gets surprised by this.

The real solution is to use lzma(2).

Cool project! Now, Zip-Ada's ReZip does much better, even if you stick with the Deflate compression scheme. For Zip archives, you have more compression schemes available (BZip2, LZMA, ...) and even much better results.