Educational guide

How Image Compression Actually Works

A clear explanation of lossy and lossless compression, why quality settings matter, and how modern formats squeeze out extra savings.

Quick answer

Lossy compression discards image data the eye is least likely to notice, primarily reducing color detail more than brightness detail. Lossless compression removes redundant data without discarding anything, so the original can be reconstructed exactly. Most image formats support one or both approaches.

How to see compression in action

1

Download and open TinyPixels

Free to install on Mac or Windows — no account needed to start.

2

Drop a photo in

Try a JPEG or PNG source you already have on hand.

3

Adjust the quality slider

Watch file size drop as you move from 100% toward 75-85%.

4

Compare original vs. compressed

Check the History tab for the exact size reduction and ratio.

Lossy compression: exploiting how eyes see

Human eyes are significantly better at detecting brightness (luminance) differences than color (chrominance) differences. Lossy compression, used by JPEG, WebP, and AVIF, exploits this by preserving brightness data in high detail while compressing color data more aggressively — a technique called chroma subsampling.

A quality setting controls how aggressively this happens. Higher quality preserves more data at a larger file size; lower quality discards more for a smaller file, with visible artifacts appearing once quality drops too far.

Lossless compression: removing redundancy, not data

Lossless compression, used by PNG and optionally WebP and AVIF, works differently — it finds statistical redundancy in the file (repeated patterns, predictable pixel sequences) and encodes it more efficiently, without discarding any actual pixel information. The decompressed image is bit-for-bit identical to the original.

Why encoders matter as much as formats

Two tools compressing the same image to the same format and quality setting can still produce different file sizes, because the encoder's internal algorithm for choosing what to discard and how to encode the rest varies. mozjpeg, for example, produces smaller JPEG files than a standard encoder at equivalent visual quality — this is why TinyPixels uses mozjpeg, oxipng, and libavif specifically rather than generic encoders.

Lossy = smaller, imperceptible tradeoff

Best for photos and web delivery at a well-chosen quality setting.

Lossless = zero data loss

Best for source files, logos, and screenshots with text.

Quality setting matters most

75-85% typically produces visually identical results at 60-80% smaller size.

Encoder choice matters too

Industry-standard encoders like mozjpeg outperform generic ones at the same setting.

What actually happens when a JPEG gets compressed

It helps to walk through the actual steps, since "discards data you won't notice" can sound vague without specifics:

1. Color space conversion

The image converts from RGB to YCbCr — separating brightness (Y) from color information (Cb, Cr) so each can be treated differently.

2. Chroma subsampling

Color channels get downsampled (commonly to a quarter resolution) since the eye is much less sensitive to color detail than brightness.

3. Block splitting and DCT

The image splits into 8x8 pixel blocks, each transformed into frequency components via the discrete cosine transform — separating smooth gradients from fine detail.

4. Quantization

A quantization table reduces precision on each frequency component, more aggressively for high-frequency (fine detail) components than low-frequency (smooth) ones. This is the main lossy step — and the one the quality setting controls.

5. Entropy coding

The quantized data gets losslessly compressed further (typically via Huffman coding), squeezing out remaining redundancy with no additional visual impact.

WebP and AVIF follow a similar overall shape — transform, quantize, entropy-code — but with more sophisticated prediction and transform techniques inherited from video codecs, which is part of why they outperform JPEG at equivalent quality.

Common misconceptions about compression

"Higher resolution always means better quality"

Resolution and compression quality are independent — a high-resolution image compressed aggressively can look worse than a lower-resolution image compressed conservatively.

"Compressing twice always halves the file size again"

Lossy compression applied repeatedly compounds artifacts without proportional additional size savings — each pass discards data the previous pass already approximated, with diminishing returns and worsening quality.

"PNG is always better quality than JPEG"

PNG is lossless, which is different from "higher quality" — a JPEG at a high quality setting can be visually indistinguishable from a PNG of the same image while being a fraction of the size, for photographic content specifically.

"A bigger file number always means better compression happened"

Compression ratio depends entirely on source content — a highly detailed, noisy source image will always compress less than a simple, flat-color one, regardless of how good the compressor is.

Frequently asked questions

How does lossy image compression work?

Lossy compression discards image data the human eye is least likely to notice. It exploits the fact that eyes detect brightness (luminance) differences far better than color (chrominance) differences, so color data gets compressed more aggressively than brightness data.

How does lossless compression reduce file size without losing data?

Lossless compression finds and removes statistical redundancy in the file — repeated patterns, predictable sequences, and unnecessary metadata — without discarding any actual pixel information. The image can be reconstructed exactly.

Why do some compression tools produce smaller files than others at the same quality setting?

Different encoders use different algorithms for choosing what to discard and how to encode what remains. For example, mozjpeg produces smaller JPEG files than a standard encoder at the same visual quality, due to smarter quantization table selection.

Does compression always make an image look worse?

No. At well-chosen quality settings (typically 75-85% for JPEG or WebP), the result is visually indistinguishable from the original at normal viewing size, even though the file is 60-80% smaller.

What is chroma subsampling?

Chroma subsampling reduces the resolution of color information while keeping brightness at full resolution, since the human eye is far less sensitive to color detail than brightness detail. A common scheme, 4:2:0, samples color at a quarter of the brightness resolution — invisible to most viewers but a meaningful size reduction.

What is a quantization table in JPEG compression?

After an image is transformed into frequency components (via the discrete cosine transform), a quantization table determines how much precision each frequency component keeps. Higher frequencies — fine detail — get quantized more aggressively since the eye notices their loss less than smooth, low-frequency areas. Encoders differ mainly in how well-tuned their quantization tables are.

Why does compressing a screenshot work differently than a photo?

Screenshots and UI mockups have large areas of flat, repeated color and sharp edges — exactly the kind of redundancy lossless compression excels at removing. Photos have continuous gradients and fine noise with little redundancy, so they benefit more from lossy compression's perceptual tricks than from lossless redundancy removal.

See it in action on your own files

Free to start. No credit card, no account, no cloud. See Pro pricing →