TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

DeflOpt Program: Optimize Compressed Files

This article describes the DeflOpt program. Deflopt can lead to better compression.

DeflOpt improves compression ratios.

It can enhance the compression ratio of your GZIP, ZIP, or PNG files that use the DEFLATE compression algorithm. We use the free DeflOpt.exe command-line executable to do this.

Example. 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.

7-Zip Executable

Note: DeflOpt "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

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.

And: The DeflOpt.exe file should be in your current directory when you run that. 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 + "\"";
}

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 tiny.

Summary. We saw that the results with DeflOpt.exe are less than stunning. But if you are already using it, DeflOpt is sometimes worth keeping, depending on your goals. If you are into compression, it is an interesting tool.

Also: You can use it on PNG and ZIP files, which I didn't test here. Experiment with it and see how it works on your project.

Programs written by Ben Jos Walbeehm


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf