Skip to content

How image compression works, and how to land exactly under a size limit

6 minutes, updated 2026-11-07

A photo from a phone is 3 to 6 MB. A form wants 50 KB. That is a hundred-to-one reduction, and the surprising thing is how little of the picture you lose when it is done in the right order. This guide explains what compression removes, which lever to pull first, and why guessing a quality number is the slow way to hit a limit.

Two kinds of compression

Lossless compression (PNG, ZIP) finds repetition and writes it more briefly. Every pixel comes back exactly. It works wonders on screenshots and flat graphics, where thousands of neighbouring pixels are identical, and does almost nothing for photographs, where no two pixels are quite alike.

Lossy compression (JPG, WebP) throws information away on purpose, starting with what eyes notice least: fine colour detail and high-frequency texture. The quality setting decides how much goes. A JPG at quality 90 is visually identical to the original on a screen; at 70 you need to look for the difference; at 40 you see blocks around edges.

What the quality number does

Quality is not a percentage of the file size. Going from 95 to 80 often halves the file with no visible change, while going from 40 to 20 saves little and looks much worse. The useful range for photos is 60 to 85. Below that, the smarter move is a different lever.

Below 50 KB, pixels matter more than quality

File size scales with the number of pixels. A 4000 × 3000 photo has 12 million of them; a 600 × 450 version has 270 thousand, forty-four times fewer. Shrinking the pixel size first is why a form photo can land at 30 KB and still look clean: the portal displays it at a few hundred pixels anyway, so the extra pixels were never going to be seen.

The order that keeps the most quality is: crop away anything that is not the subject, resize to the pixel size the destination will display, then lower quality only as far as the limit needs.

Why hitting an exact limit needs a search

Two photos at the same quality setting produce very different file sizes, because a plain wall compresses far better than a crowd. There is no formula that maps quality to kilobytes. The reliable way is to encode, measure the real file, and adjust: too big, lower quality; room to spare, raise it. A binary search does this in about seven tries and finishes within a few percent under the limit, which is what the fit-to-size tool on this site does, in your browser.

Metadata is free savings

Cameras attach an EXIF block with the lens, settings, GPS position and often a full thumbnail. It is 20 to 60 KB on its own, which can be the whole budget for a form upload. Re-encoding through the browser writes a clean file without it, and removes the GPS location from the file as a side effect.

Choosing the format

ContentBest formatWhy
PhotographsJPG (WebP if accepted)Lossy compression suits continuous tone
Screenshots, UI, textPNG (WebP if accepted)Sharp edges stay sharp; flat areas are tiny
Logos with transparencyPNG or WebPJPG cannot store transparency
Form uploadsWhatever the form lists, usually JPGThe rule wins over the theory

A short checklist for a stubborn upload

  • Read the rule fully: format, maximum size, sometimes a minimum size, and the pixel dimensions.
  • Crop to the subject.
  • Resize to the required pixels, or to about the size it will be shown at.
  • Use the fit-to-size tool with the exact limit, in the required format.
  • Check the result's dimensions and size in the row before you download.

Tools for this