logoalt Hacker News

Make ZIP files smaller with ZIP Shrinker

48 pointsby zdwlast Sunday at 12:26 AM34 commentsview on HN

Comments

Wowfunhappytoday at 12:32 PM

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.

show 1 reply
KerrickStaleytoday at 1:04 PM

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

show 1 reply
lifthrasiirtoday at 8:20 AM

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

show 2 replies
akxtoday at 6:51 AM

> 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?

billpgtoday at 11:06 AM

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.

show 1 reply
jurgenkeskertoday at 8:46 AM

APKs need to be zipaligned, I don't see that mentioned.

show 2 replies
seritoolstoday at 10:36 AM

> 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)

ChrisNorstromtoday at 10:09 AM

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.

show 2 replies
stuaxotoday at 8:50 AM

Nice, interesting to see if it helps docx much.