OxiPNG and Pngout

One thing that had stuck with me from reading Coding Horror, is that you can increase the speed of your website with free bandwidth. In fairness, it’s not free bandwidth, it’s reducing the file size of the files that you’re hosting, so it’s faster to download. The Zopfli article above is the more recent one - the first was regarding pngout (article).

Both pngout and zopfli can reduce the size of files - specifically in this case, PNG files. There are other options for JPEG’s etc, but I’m focusing on PNG files for now. These are most commonly created from screenshots from PC’s or phones 1.

I use these files a lot, so I’ve always run the files through Imageoptim on the Mac, even if I’m not uploading them to the web - after all, it’s saving me disk space as well 2!

OxiPNG

On Windows however, I’ve not got the same tools at my disposal, so I’ve been living with pngout.

However, whilst browsing Google, I stumbled upon Oxipng. I decided to try it instead of pngout, and I’m glad I did, as it seems to outstrip pngout in speed and compression.

I took a screen shot and saved it twice, running one through pngout and the other through oxipng. Both commands were saved as batch files, with the files dropped on to the respective batch file to run.

Pngout was setup as:

 start pngout %1 /y

oxipng was setup as:

 oxipng -o 4 -i 0 --strip safe %1

This sets the optimisation level of the software, as well as interlacing options. I set the optimisation level to level 4, bearing in mind the warning from oxipng’s website

Optimization: -o 1 through -o 6, lower is faster, higher is better compression. The default (-o 2) is sufficiently fast on a modern CPU and provides 30-50% compression gains over an unoptimized PNG. -o 4 is 6 times slower than -o 2 but can provide 5-10% extra compression over -o 2. Using any setting higher than -o 4 is unlikely to give any extra compression gains and is not recommended.

As such, as I was expecting it to take a while.

Both starting files were the same and were almost 2MB in size.

Before

Putting one through pngout and the other through oxipng gave me the following:

After

For oxipng, that’s about a 34% reduction, pngout giving 11% reduction. And speed wise, I had to check, as oxipng ran so quick, the command window closed so quickly, I thought I’d run in to an error!

So it’s reducing the PNG files to a smaller size, as well as running far faster!

Conclusion

I couldn’t see any visible differences between what was shown in the two files, so I’ve switched to using OxiPNG for all my PNG reductions now. It seemed like a no brainer to have something that would run faster and make smaller files replace the older software. I’ll perhaps see how things go, but for now, I see no reason why I would switch back.


  1. Though, for whatever reason, Oneplus abandoned it in favour of JPEG - not sure if this is the same in the newer versions of the Oneplus, but it put me off the 7 when I had it! ↩︎

  2. I’d often use it on JPEG’s as well to strip EXIF data, like location data, if I didn’t want that information in te public. ↩︎