Image compression explained: lossy, lossless, and why no tool can hit an exact KB

How image compression actually works: what lossy and lossless remove, what a quality setting means, and why "exactly 50 KB" is not achievable — explained plainly.

Published and last reviewed · Independent explainer — sources are linked, and nothing here is an endorsement.

Two families of compression

Image formats either throw away nothing or throw away detail on purpose, and everything else follows from that one difference.

Lossless formats (PNG, and the lossless mode of WebP and AVIF) compress by describing the same pixels more cleverly. Run the file through a lossless encoder ten times and the picture never changes — the only question is how much redundancy the encoder can find. That is why a detailed PNG often barely shrinks: there was not much redundancy to remove.

Lossy formats (JPEG, WebP, AVIF in their normal modes) discard information the human eye is unlikely to miss: fine texture, subtle colour variation, high-frequency detail in flat areas. That is what produces tenfold savings — and it is also why the result is never byte-identical to the original.

What a quality setting actually means

A quality value is not a percentage of the file and not a promise about appearance. It is an input to a specific encoder, and each encoder interprets it differently: the same 0.8 produces different sizes and different artefacts in JPEG, WebP and AVIF.

Two consequences follow. First, the same quality setting on two different photos can give wildly different file sizes, because photographs with more detail cost more bits to describe. Second, a quality value can only be tuned by measuring: encode, look at the size, adjust. Every slider-only compressor does exactly that internally — this site just lets you see the measurements.

Why "exactly 50 KB" is impossible

Encoders quantise their output, and quantisation does not land on round numbers. Even if a target were reachable in theory, the search itself moves in steps: quality 0.62 might produce 51.4 KB and quality 0.61 might produce 49.8 KB, with nothing in between. There is no setting that produces exactly 51,200 bytes.

This is why the honest wording is "at or under your limit", and why a serious tool reports what it achieved instead of claiming the number you typed. A tool that promises an exact byte count is either padding the file or quietly ignoring the target.

The three levers you actually control

There are only three ways to make an image file smaller, and they trade against different things.

LeverWhat it doesTypical savingCost
QualityDiscards fine detail the eye rarely noticesLarge for photos, small for graphicsVisible artefacts if pushed too far
PixelsStores the image at a smaller resolutionVery large (squared effect)Less detail when enlarged or printed
FormatPicks a container with a better encoderModerate, sometimes largeCompatibility with older software

How to choose a target that a portal will accept

Forms state ceilings, not goals: 20 KB, 50 KB, 100 KB, 200 KB. Treat the ceiling as the goal and let the tool find the highest quality that fits. If the ceiling is impossible at full resolution, the useful question is not "compress harder" but "how large does this image actually need to be" — a 4000-pixel photo displayed in a 300-pixel form field is wasting everything above 300.

That order of operations matters: set the size the destination needs, then compress to the ceiling. Doing it the other way round produces a tiny file that still has to be scaled down at the destination, which is why the exact-size compressor offers dimension reduction as an explicit second step rather than a silent one.

Sources

Specifications and platform behaviour change. Values on this page were reviewed on ; if a source contradicts this page, the source wins — and the correction belongs in the issue tracker.

Frequently asked questions

Does compressing an image twice lose more quality?

Yes, if both passes are lossy: each re-encode discards a little more detail, and artefacts compound. Compress from the best original you have, once. Lossless passes (PNG, or lossless WebP) can be repeated freely with no change to the picture.

Is a smaller file always a lower quality image?

No. Removing metadata, choosing a better format, and matching the pixel count to the real display size all shrink a file without touching perceived quality. Re-encoding at the same quality can also produce a smaller file if the original encoder was wasteful.

Why does my 4 MB photo sometimes not get smaller?

Usually because it is already efficiently encoded. A JPEG straight from a phone camera has typically been compressed once already; re-encoding at similar quality cannot recover much. The real savings come from pixels or format, not from a second lossy pass.

What is the best quality setting?

For photos, around 0.8 is the point where most people stop seeing a difference at normal viewing sizes; 0.9 is safer for large prints, 0.6 for thumbnails. Because encoders differ, treat those as starting points and check the before/after yourself.