whatisgithub

What is mozjpeg?

mozilla/mozjpeg — explained in plain English

Analysis updated 2026-06-26

5,675CAudience · developerComplexity · 3/5LicenseSetup · moderate

In one sentence

MozJPEG is a drop-in JPEG compression library from Mozilla that produces smaller image files than standard encoders with no visible quality loss, ideal for image pipelines that need to serve photos faster over the web.

Mindmap

mindmap
  root((mozjpeg))
    What it does
      Smaller JPEG files
      Same visual quality
      Drop-in replacement
    Techniques
      Trellis quantization
      Progressive encoding
      Quality presets
    Built on
      libjpeg-turbo
      Same C API
    Use cases
      Image pipelines
      Web services
      Photo export
    Audience
      C developers
      Backend engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Swap libjpeg for MozJPEG in an existing image pipeline to get smaller JPEG files with no code changes

USE CASE 2

Losslessly re-compress existing JPEG files using progressive encoding to reduce their size without re-encoding

USE CASE 3

Embed MozJPEG in a web service that generates JPEG thumbnails to cut bandwidth costs

USE CASE 4

Use the included command-line tool to test compression output before integrating the library

What is it built with?

Clibjpeg-turbo

How does it compare?

mozilla/mozjpegpufferai/pufferlibkbengine/kbengine
Stars5,6755,6775,684
LanguageCCC
Setup difficultymoderatemoderatehard
Complexity3/54/55/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

Must compile from source and link as a C library, no package manager install available for the library itself.

Open source under a combination of the IJG, BSD, and zlib licenses, use and embed freely in your own software.

So what is it?

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.

Copy-paste prompts

Prompt 1
Show me how to link MozJPEG into a C program that reads a PNG and saves a compressed JPEG using trellis quantization.
Prompt 2
Use MozJPEG's command-line tool to re-compress all JPEG files in a folder with progressive encoding and report the file size savings.
Prompt 3
How do I replace libjpeg with MozJPEG in an existing C++ image processing application without changing any API calls?
Prompt 4
Write a CMake build script that compiles MozJPEG from source and links it statically into a Go image service via cgo.
Prompt 5
Compare MozJPEG versus standard libjpeg-turbo output quality and file size at quality setting 85 using the demo tool.

Frequently asked questions

What is mozjpeg?

MozJPEG is a drop-in JPEG compression library from Mozilla that produces smaller image files than standard encoders with no visible quality loss, ideal for image pipelines that need to serve photos faster over the web.

What language is mozjpeg written in?

Mainly C. The stack also includes C, libjpeg-turbo.

What license does mozjpeg use?

Open source under a combination of the IJG, BSD, and zlib licenses, use and embed freely in your own software.

How hard is mozjpeg to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is mozjpeg for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.