SnapReduce
JPEG & JPG

JPEG Compression Explained

SnapReduce Technical TeamPublished 2026-09-187 min read

Every day, billions of JPEG images are transmitted across the internet. But what actually happens when you compress a JPEG? Behind the slider lies one of the most brilliant mathematical achievements in digital history.

Step 1: Color Space Conversion (RGB to YCbCr)

Screens display pixels as Red, Green, and Blue (RGB). The JPEG algorithm first transforms RGB into YCbCr, separating Luminance (Y = brightness) from Chrominance (Cb = blue difference, Cr = red difference).

Step 2: Chroma Subsampling

Because human vision has much lower acuity for color than brightness, the compressor averages color information across 2x2 pixel blocks (4:2:0 subsampling), instantly shedding 50% of the raw data before any compression math even begins.

Step 3: Discrete Cosine Transform (DCT)

The image is divided into 8x8 pixel blocks. The Discrete Cosine Transform translates each block from spatial pixel coordinates into frequency coefficients, isolating low-frequency flat shades from high-frequency fine details.

Step 4: Quantization (Where Loss Happens)

Quantization divides frequency coefficients by values in a quantization matrix. High-frequency variations are rounded to zero. This step is where data loss occurs and where the 'quality slider' operates.

Step 5: Run-Length & Huffman Coding

The remaining non-zero numbers are sequenced in a zigzag pattern and compressed losslessly using Huffman coding to produce the final, compact JPEG file.
Recommended Utility

Experience smart JPEG compression

Our engine executes this exact pipeline directly in your browser.

Try JPG Compressor

Questions & Answers

Can JPEG compression be undone?

No, quantization permanently discards subtle high-frequency data.