Mozilla to improve JPEG compression with mozjpeg tool

March 6, 2014 by Nancy Owano

Mozilla to improve JPEG compression with mozjpeg tool

8x8 pixel subimage used as an example for JPEG. Credit: Wikipeida

( —Mozilla announced on Wednesday its new project to provide a production-quality JPEG encoder that improves compression. Project mozjpeg will bring better compression efficiency to JPEG, the popular image format with proven staying power since 1992. The Wednesday blog announcement from the Mozilla Foundation presented reasons for the launch. The number of photos that the average Web site displays has grown over the years, as has the size of those photos. HTML, JS, and CSS files are relatively small in comparison. The Mozilla blog noted too that photos can easily make up the bulk of the network traffic for a page load. "Reducing the size of these files is an obvious goal for optimization." Why did the Mozilla team focus on JPEG specifically? The announcement had an answer for that too.

"Nearly every photograph on the Web is served up as a JPEG. It's the only lossy compressed image format which has achieved nearly universal compatibility, not just with Web browsers but all software that can display images."

The mozjpg project was the result of frequent discussions over JPEG encoders. "Production JPEG encoders have largely been stagnant in terms of efficiency, so replacing JPEG with something better has been a frequent topic," said the blog." (End-users gain from compression in that smaller files arrive much faster but compression can be tricky. Poor use of compression can result in a sacrifice in image quality.)

Discussions at Mozilla involved whether JPEG encoders, after over 20 years, had really reached their full compression potential. The answer even within constraints of compatibility requirements was no. The mozjpeg software is at version 1.0 now, on GitHub. The tool is actually a fork of libjpeg-turbo with 'jpgcrush' functionality added. Mozilla Corporation's Senior Technology Strategist Josh Aas, author of the Wednesday blog post, said, "We noticed that people have been reducing JPEG file sizes using a perl script written by Loren Merritt called 'jpgcrush', references to which can be found on various forums around the Web. It losslessly reduces file sizes, typically by 2-6% for PNGs encoded to JPEG by IJG libjpeg, and 10% on average for a sample of 1500 JPEG files from Wikimedia."

Aas also said the next goal in the project is to improve encoding through the use of trellis quantization, an algorithm to improve data compression.

More information:

add to favorites email to friend print save as pdf