DengWoLai DengWoLai

Compress an Image to 20 KB Without Destroying It

Why hitting an exact target size damages text and faces, which setting does the damage (not the one you think), and how to check whether the result is still readable before you upload it.

“Maximum file size: 20 KB” is a common upload requirement — job portals, visa forms, exam registrations. And the usual result is a photo that technically passes and looks like a watercolour painting.

The file size isn’t the problem. How the tool gets there is.

What’s actually being thrown away

JPEG compression has two independent stages, and they do different kinds of damage:

Chroma subsampling halves the colour resolution: the image keeps full brightness detail but stores colour at half resolution in each direction. Skin tones stay smooth; sharp colour edges get muddy. Usually the first thing to go.

Quantisation divides the DCT coefficients by a table of values and rounds. High-frequency detail — fine texture, thin strokes, text edges — gets rounded to zero. This is where the visible damage comes from.

A tool chasing 20 KB will push both aggressively. The question is whether it pushes them intelligently.

The mistake most tools make

To hit an exact byte target, a compressor has to search: encode at some quality, measure, adjust, repeat. Most implementations do a linear scan — start at 0.9, step down by 0.1 until it fits.

That produces a file that’s smaller than it needed to be. If quality 0.6 lands at 18 KB and the limit is 20 KB, the scan stops, but quality 0.65 might have hit exactly 20 KB with noticeably better detail. The tool never checks.

The result: a photo at a quality level chosen by a step size, not by the image.

What to do instead, in order

Before touching quality, exhaust the free wins:

1. Resize first. A 4000×3000 photo compressed to 20 KB is doomed. The same photo at 1200×900 compresses to 20 KB at reasonable quality. If the form only displays it at 300 px wide, you’re storing pixels nobody sees.

2. Crop. A lot of file size is background. Cropping to the subject can remove 40% of the pixels with no loss of information.

3. Only then lower quality. And check the result, don’t assume.

That order matters because resizing is lossless in perception up to the display size, while quality reduction is lossy everywhere.

How to check the result before uploading

Open the compressed file at 100% zoom and look at:

  • Text. Small text is the first casualty. If letters have halos or grey mush around them, the file is over-compressed for its purpose.
  • Straight high-contrast edges. Window frames, glasses, document borders. Quantisation makes them ring.
  • Faces at small size. Skin is forgiving; eyes and teeth are not.

If it’s a document scan with text, don’t use JPEG at all — use PNG or push toward higher quality and crop harder. JPEG is designed for photographs; it punishes exactly the high-contrast detail text is made of.

A realistic expectation

For a typical phone photo:

Target Result
500 KB Looks identical on screen
100 KB Fine for web, slightly soft at 100%
20 KB Acceptable as a thumbnail or form upload; visibly degraded at full size

20 KB is roughly a 300×300 thumbnail’s worth of data. If your requirement says 20 KB and the photo will be viewed large, no compressor can satisfy both — the requirement is the problem, and resizing is the honest answer.

On our side

Compress an image does a binary search on quality rather than a linear scan, so it lands near the target instead of well under it. It also lets you set the pixel dimensions in the same step, which is the fix that actually matters.

Exact-size presets: 20 KB, 100 KB.

Everything runs locally — the image is decoded and re-encoded in the browser, never uploaded.


Related: why HEIC photos won’t open on Windows, why “redacted” screenshots still show the text