DeflOpt Utility

Dot Net Perls
Program icon (copyright Microsoft)

You want to improve the compression ratio of your GZIP, ZIP, or PNG files that use the DEFLATE compression algorithm. Use the free DeflOpt.exe command-line tool to do this. Here we look at how you can use DeflOpt and what it can help with.

Usage

First we note that even after the highest compression from 7-Zip or other tools, DeflOpt.exe can often reduce your file size by one or more bytes. This tool is written by Ben Jos Walbeehm and is available from his site. From the site, the description for DeflOpt is that it "optimizes the structures created by deflate programs and then recodes the files using those optimized structures."

Windows command line for Deflopt

deflopt.exe C:\yourfolder

Testing the program. To test the program on many files, I created a method in the C# programming language that runs the DeflOpt.exe program against an entire directory. Above you can see the command line for running DeflOpt.exe on a directory. The DeflOpt.exe file should be in your current directory when you run that. Next, here is the C# code I use to automate this command.

Method that executes Deflopt.exe [C#]

/// <summary>
/// Run DEFLOPT on compressed files directory
/// Improves compression ratios minutely
/// </summary>
public static void CompressDirDeflopt(string dir)
{
    ProcessStartInfo p = new ProcessStartInfo();
    p.FileName = Locations.DefloptExe; // Location of DeflOpt.exe
    p.Arguments = string.Format("{0}",
	Quote(dir));
    p.WindowStyle = ProcessWindowStyle.Hidden;
    using (Process x = Process.Start(p))
    {
	x.WaitForExit();
    }
}

/// <summary>
/// Surround string with quotes
/// </summary>
static string Quote(string s)
{
    return "\"" + s + "\"";
}

The DeflOpt.exe results. When I run the command on a directory of 296 files with the maximum GZIP compression in 7-Zip, 17 of them are rewritten for a total savings of 17 bytes. That is a total savings of 0.0000164%. However, if I use a lower initial setting in 7-Zip, I get a savings of 147 bytes, around 10 times as much, which is still very tiny.

Summary

We saw that the results with DeflOpt.exe are less than stunning, but if you are already using it, it is sometimes worth keeping, depending on your goals. If you are into compression like I am, it is an interesting tool. You can also use it on PNG and ZIP files, which I didn't test here. Experiment with it and see how it works on your project.

Linked page Compression Tips