gitmyhub

mozjpeg

C ★ 5.7k updated 1y ago

Improved JPEG encoder.

MozJPEG is a JPEG compression library created by Mozilla. Its main purpose is to make JPEG image files smaller without making them look worse. It achieves this by applying smarter compression techniques than older standard encoders, so the same image takes up less disk space or downloads faster over the internet, while looking essentially the same to the human eye.

The project is built on top of libjpeg-turbo, which is a widely used open-source JPEG library. MozJPEG adds extra compression features on top of it, including a technique called trellis quantization that squeezes out more file size when converting photos from other formats to JPEG, and progressive encoding optimization that can losslessly shrink any existing JPEG file. It also ships with new quality presets tuned for high-resolution screens.

Because it follows the same programming interface as the standard libjpeg library, developers can swap it into an existing graphics program without rewriting any integration code. The extra compression features can also be turned off at runtime, in which case the library behaves exactly like libjpeg-turbo. Output files are compatible with all standard JPEG decoders, including every major web browser.

MozJPEG is meant to be used as a library that gets embedded inside image editing tools, photo export pipelines, or web services that generate JPEG files. It includes a command-line demo tool, but that is provided for testing rather than everyday use. Developers who want to use it should link their program against the MozJPEG library directly.