Mozilla’s New JPEG Encoder Promises Up To 10% Reduction In File Size

Mozilla is launching mozjpeg today, a new JPEG encoder that promises to reduce file sizes by up to 10 percent on standard JPEG images. Mozilla says the idea behind the project is to create a production-ready encoder “that improves compression while maintaining compatibility with the vast majority of deployed decoders.”

Despite multiple efforts from Google, Microsoft and others, JPEG remains the de facto standard for lossy compression. Even though formats like JPEG XR (or HD Photo, as Microsoft called it), JPEG 2000 and Google’s WebP have significant advantages over the base JPEG format, they never got the wide-reaching support necessary to replace JPEG. Besides PNG for lossless images, JPEG still remains the standard for images on the web, which now account for the majority of network traffic whenever you load a webpage.

As Josh Aas, a senior technology strategist at Mozilla, notes today, the compression efficiency of JPEG encoders hasn’t seen any major improvements lately. That’s one of the reasons why new formats regularly spring up. Mozilla, which so far hasn’t backed Google’s WebP Project, for example, acknowledges that at some point, the new formats will be so good that we will inevitably switch. Until then, though, we are stuck with JPEG.

To push JPEG further, the team forked libjpeg-turbo, a popular open-source JPEG codec, and combined it with jpgcrush, a popular Perl script written by Loren Merritt. Jpgcrush goes through a number of options for compressing the image and then picks out the one that creates the smallest files. The Mozilla team believes this is the first time a production encoder has used this functionality.

Looking at 1,500 images from Wikimedia, the combination of these two applications resulted in an average reduction in file size of about 10 percent. For PNG images that were already compressed with a standard JPEG encoder, the extra step dropped the file size by 2-6 percent.

So far then, this project looks like a cool hack that combines a number of existing products. Looking ahead, though, Mozilla plans to add more features to this tool and is looking at making use of trellis quantization, for example. I had no idea what that is, but as far as I can see after a bit of time on Google, it’s an algorithm that can be used to improve the lossy compression algorithms that form the basis of the JPEG format. Currently, it seems, it’s mostly being used for video compression.

Image by Flickr user hellocatfood under CC By 2.0