How can I achieve the best, standard ZIP compression?

I don't care how long it takes to compress, all I want to achieve is two things:

  • The absolute best possible compression ratio
  • Compatibility with standard readers, such as Windows and WinZip

So suggestions such as 7-zip won't be of much use, unless 7-zip is also slightly better at the standard ZIP compression (as opposed to using it's very good .7z format).

Ideally I'm looking for:

  • A recommendation of a piece of software
  • The particular settings for that software that enable the absolute best compression
  • Something that's free

Remember, how long it takes to compress is not an issue!

One last thing - some files might be better compressed with different settings, like the "Word size" or "Dictionary size" - is there a tool that can analyse the files and choose the most appropriate compression ratio, or does WinZip, 7-zip etc. already do that?


Solution 1:

If you want compatibility with the Zip Folders capability built into Windows XP, you're stuck with Deflate compression. I don't think you can even use Deflate64, much less the advanced compression methods (like LZMA, PPMD, WavPack, Bzip2, etc.) available in recent versions of winZip and PowerArchiver. PowerArchiver at least defaults to using the .zipx extension for those files -- I don't think WinZip is doing that yet.

The smallest possible zip file that 7-Zip can create can be done with the following command line:

7za a -mm=Deflate -mfb=258 -mpass=15 -r C:\Path\To\Archive.zip C:\Path\To\Files\*

Of particular note: 7-Zip's wildcard parser is not the same as most others on the system. *.* means all files that have extensions. * means all files.

Creating .zip files this way (and, presumably, using other tools that attempt to make smaller "standard" .zip files) is really, really slow. You would most likely save considerable time and space by using 7-Zip or WinRar to create self extracting archives.

Solution 2:

The best deflate (the compression format used by standard ZIP) compressors that I know of are:

  • Zopfli
  • KZip
  • 7-zip - 7­zip ­mm=Deflate ­mx=9

Deflate file compressed file size comparison from Data compression using Zopfli (archived from original):

╔══════════════╦═══════════╦═════════╦═════════╦═════════╦═════════╗
║              ║Corpus size║gzip ­-9  ║7-­zip    ║kzip     ║Zopfli   ║
╠══════════════╬═══════════╬═════════╬═════════╬═════════╬═════════╣
║Alexa-top-10k ║  693108837║128498665║125599259║125163521║123755118║
║Calgary       ║    3141622║  1017624║   980674║   978993║   974579║
║Canterbury    ║    2818976║   730732║   675163║   674321║   669933║
║enwik8        ║  100000000║ 36445248║ 35102976║ 35025767║ 34995756║
╚══════════════╩═══════════╩═════════╩═════════╩═════════╩═════════╝

Even on random PNGs Zopfli was able to be 0.5% better than pngout. Zopfli makes the smallest of them all.

Solution 3:

Assuming you are on Windows: if you still want to use the ZIP format, I would recommend using Ken Silverman's free KZIP command-line utility, found here. Copy it inside the folder containing all the files you need to compress, go to that folder using CMD, and run the following command:

kzip /r <filename of ZIP file> *.*

As Roald suggests, it's best to include the directory where kzip.exe resides in your system's PATH variable to prevent it being included in the archive/Zip file.

So far, I've found the ZIP files created with KZIP is around 10-20% smaller than the ones created by other ZIP compressing programs. They're also fully openable by other archive software (Winzip, WinRAR, 7-zip, etc.) and by Windows.