JPEG Compression

Manage your Photos: JPEG Photo Compression

Last Updated on July 22, 2020

MozJPEG with compression charts

Libjpeg is the baseline cross-platform JPEG encoder, maintained by an informal independent group. It’s mature software with its first release back in 1991. It tries to balance encoding speed, quality, and file size. Libjpeg-turbo is intended to be a higher performance replacement for libjpeg.

MozJPEG is a fork of libjpeg-turbo. MozJPEG’s objective was to reduce file size to serve images on the web faster and reduce bandwidth. Obviously a very important consideration for Mozilla. MozJPEG uses progressive coding and trellis quantization. Trellis quantization is an adaptive quantization technique that select the set of levels in a transform block that minimizes a rate-distortion metric.

MozJPEG is designed as a library in graphics programs and image processing tools. It can be seamlessly integrated into any software using libjpeg – it’s a drop-in replacement. It’s written in the C programming language.

The project includes a standalone binary called cjpeg. This tool is not intended for production use. We run a number of tests with cjpeg on a 7.3MP JPEG image.

The -quality switch lets you trade off compressed file size against quality of the reconstructed image: the higher the quality setting, the larger the JPEG file, and the closer the output image will be to the original input. For example, the command below compresses the file.jpg with quality at 85.

$ cjpeg -quality 85 file.jpg > file-output.jpg

Normally you want to use the lowest quality setting (smallest file) that decompresses into something visually indistinguishable from the original image. From our tests, we found the quality setting is best around 70-85. But if you’re looking to produce an index for a large image library, you could lower the setting to under 10.

As the chart below shows, the compression percentages are very impressive.

JPEG Compression: MozJPEG 7MP

For reference purposes, Q-84 is the result with Guetzli (with quality setting at its minimum 84) on the same 7.3MP photograph.

We ran the same tests with a rather squishy 36MP JPEG. Again Q-84 is the result with Guetzli (quality set at 84). Witness the huge savings of storage space and bandwidth with the compressed images.

JPEG Compression: MozJPEG 36MP

Next page: MozJPEG – Time chart

Pages in this article:
Page 1 – Introduction
Page 2 – Guetzli – Compression charts
Page 3 – Guetzli – Time chart
Page 4 – MozJPEG – Compression charts
Page 5 – MozJPEG – Time chart
Page 6 – Lepton – Compression charts
Page 7 – Lepton – Time chart
Page 8 – Summary

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jiff
Jiff
3 years ago

According to the tests I made some years ago to be able to store efficiently invoices and other enterprise documents scans into a document management software without artifacts, even on very small letters, tests that I also extended to web sites pictures processing, here is what I found :

using GIMP as the graphic manipulation program with a :
* progressive .jpg encoding for slow connections enabled,
* 4:4:4 Subsampling method,
* Floating-point for the DCT method,
* only exif data kept (no thumbnail or other orientation/dimensions system)
*** and the most important feature : image colors indexed into a 256 colors optimized palette,

the threshold not to cross to be absolutely sure there will be no artifacts in the final picture, nor color problems (except, of course, with gradations, that do not fit in this process) is : 65 %.

My 2¢