35

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?

BenMorel
  • 1,011
Josh Comley
  • 4,122

6 Answers6

29

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.

afrazier
  • 23,505
11

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

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.

Anon
  • 1,431
6

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.

Isxek
  • 3,965
1

Super simple script to compress all folders in a folder to individual zip files using .zip filetype and a Deflate64 compression method.

@echo off
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\" -tzip -mx9 -mm=Deflate64
-1

It's more a limit of how much memory you have to make available to the compressor while it's doing it's job. Using 7-Zip, I'd pack an archive with .Zip format, Ultra compression, LZMA compression method, and the default 64MB dictionary size. If you have the memory available, then up the dictionary size, though note that you'll need almost 3GB of memory available to compress with a 64MB dictionary. Using a larger dictionary should allow 7-zip to hunt for more matches and provide better compression if you can afford the memory. LZMA beats both gzip (deflate/deflate64, I think) and bzip2 by a good 5% on average, up to 10-12% depending on the content.

I don't know of a tool to find the best word/dictionary size, though I think you'll find that compression method has a stronger correlation with input data, and the average/defaults should be good otherwise.

Darth Android
  • 38,658
-3

If you are looking for the best compressor for Windows environments, I would recommend you to try either *.zip format with 7-zip LZMA 'Compression Method' OR use 7-Zip *.7z SFX archives . SFX archives have a overhead of about 130 kb over .7z compressed files and are worth using when the size difference between .7z and .zip is large.

Another good but uncommon competitor is the NSIS which can use LZMA compression mode to create highly customizable exes. I know NSIS is not an compressor but a Scripting language but I was impressed it performed better than 7-zip SFX.

A Test I did with 2 files -

  • AutoHotkey-H.exe (946 kb)
  • AutoHotkey.dll (1003 kb)
  • Total Size - 1955 kb

  • 7-Zip .zip - 794 kb
  • 7-Zip .7z SFX - 594 kb
  • NSIS LZMA Solid Compression - 552 kb
  • 7-Zip .7z - 461 kb

As #4 is not what you want, the clear winner is NSIS but for practical reasons, I suggest going with .zip is compressed size is less than 500 kbs and if larger, go with a exe making tool such as 7-Zip SFX or NSIS (7-zip in particular as it is easy to set up).

Giacomo1968
  • 58,727
Avi
  • 242
  • 2
  • 9