2014-05-23

PngOptimizer 2.4

I updated PngOptimizer but the main changes are under the hood. The most important change is the porting to Linux (and to g++ and GNU Make) of the source code needed to build PngOptimizerCL, the command line version of PngOptimizer. You will find a new link on the PngOptimizer page to download a tar.gz archive containing the compiled version for x64.

PngOptimizerCL for Linux

Some porting was not always obvious as I previously made assumptions I thought was common to all operating systems, but was in fact Windows specific. For example, the arguments given to a process are parsed by the process itself on Windows, and by the calling process on Linux. I initially wrote a function to parse the command line but I could not port it to Linux. I rewrote the parser to work with argc/argv instead.

Another example is the use of a wildcard (like *.png) when looking for specific files. The Windows API has a built-in matcher for this kind of expression. On Linux, you either let the calling process do the job (usually, the Terminal) or you embed your own matching code. Thus I rewrote my code that reads directories, ensuring the same behavior on Windows and Linux by using a file matcher that is enabled on both platforms.

I hope I did not break anything by rewriting those functions. I ported my unit tests and wrote new ones, they all pass but it is easy to forget some corner cases.

Because of the various flavors of Linux distributions, I cannot guaranty that it will work on any Linux, but at least it works on Ubuntu 14.04 for x64:) So far it is working well, and as a bonus, I measured a 25% performance boost in comparison with Windows! I don't know if it is because of g++ or Linux itself, but it was a nice surprise.

The GUI version will be a bit more difficult to port because it relies completely on the Windows graphics API. It means I will have to write a new GUI from scratch for Linux. I think I will choose GTK+ as it is the default GUI toolkit on Ubuntu but I need to learn how to use it.

I also migrated the source code from Visual Studio 2010 to Visual Studio 2012. I initially wanted to install Visual Studio 2013 but the installation failed as it requires Windows 8. I am still using Windows 7 and I don't feel like upgrading.

Anyway, enjoy that new release!