Image tools

How to Compress an Image to a Specific Size in KB

How to compress a photo to exactly 20 KB, 50 KB or 100 KB for an exam or job application form - what the limit means in bytes, why quality alone is not always enough, and how to hit the number without wrecking the picture.

6 min readUpdated Aug 10, 2026

The form says the photograph must not exceed 50 KB. The photograph on your phone is 4 MB - eighty times too big. Upload portals enforce these limits strictly and almost none of them offer a way to meet one, so the job falls to you. The usual advice, "just compress it", skips the part that decides the outcome: a fixed byte budget can be spent well or badly, and the difference is whether the person at the other end sees a face or a grid of grey squares.

What the limit actually means in bytes

A kilobyte is almost always 1,024 bytes rather than 1,000, so a 50 KB cap means 51,200 bytes. That is the figure Windows, macOS and most upload validators use, and it is the one worth working to.

A minority of portals do their arithmetic in round decimal thousands, making the same 50 KB limit 50,000 bytes - 1,200 bytes tighter, a difference of about 2.4 per cent. It is small, but it is exactly the margin a tool aiming to land just under 51,200 will occupy. If a file that looks comfortably inside the limit is rejected anyway, this is the usual reason: set the target a couple of kilobytes lower and try again.

The two dials that change a file's size

Only two things determine how large a JPG comes out, and understanding the split is most of the battle.

  • Quality - how aggressively the encoder discards detail. JPEG works on 8x8 blocks of pixels; lowering the quality rounds off more of the fine variation inside each block. Push it far enough and the blocks stop blending and become visible as squares.
  • Pixel count - how many pixels there are to encode in the first place. This one multiplies everything: halving both width and height quarters the number of pixels, and roughly quarters the file.

PNG has neither dial in a useful form. It is lossless, so there is no quality setting to turn - the only way to shrink a PNG is to remove pixels or reduce the number of colours. That is why every tool that hits a byte target writes JPG or WebP instead, and why a PNG you feed in comes back as one of those two.

A worked example: spending a 50 KB budget

Convert the target into a per-pixel allowance and the whole problem becomes obvious. 50 KB is 51,200 bytes, or 409,600 bits. How far that stretches depends entirely on how many pixels have to share it.

Take a 640x480 photo - 307,200 pixels. Each pixel gets 409,600 / 307,200, about 1.33 bits. Uncompressed colour costs 24 bits per pixel, so this asks JPEG for roughly an 18:1 reduction. That is unremarkable; JPEG holds up well down to about 1 to 2 bits per pixel, and the result will look like a normal, slightly soft photograph.

Now hand the same 50 KB to a 4000x3000 phone photo - 12,000,000 pixels. Each pixel now gets 409,600 / 12,000,000, about 0.034 bits: a 700:1 reduction. The encoder will still produce a file, because there is always some quality setting low enough. It will simply look terrible, because there is not enough information left to describe twelve million pixels.

That comparison is the whole argument for resizing. When a target sits far below what your image's dimensions can carry, cutting the pixel count is not a compromise on the way to the answer - it is the answer.

Hitting the number

Guessing at a quality slider and re-checking the size in your file manager is slow, and it is why people end up with a 47 KB file when they were allowed 50. The Compress Image to Size tool does the search instead: it re-encodes repeatedly, hunting for the highest quality whose output still fits your limit, and reduces the dimensions only when quality alone cannot get there.

  1. Drop in your JPG, PNG or WebP. The original dimensions and file size appear underneath so you know what you are starting from.
  2. Type the limit in the target box, or use one of the presets - 20 KB, 50 KB, 100 KB, 200 KB, 500 KB and 1 MB cover most forms.
  3. Leave the output as JPG unless you know the portal accepts WebP. WebP is usually 25 to 35 per cent smaller at the same visual quality, which buys real detail at a tight target - but only if allowed.
  4. Leave "shrink the dimensions" ticked. It only acts when the target is unreachable at your current size, and it is what makes a 20 KB cap achievable on a phone photo.
  5. Press compress, then check the result panel: it shows the byte count against your budget, the final dimensions, and the quality it settled on.

If the image already fits the limit, it is handed back untouched rather than re-encoded - re-compressing an already-small JPG throws away detail for no reason, and at a generous target can even come out larger than it went in.

The limits forms tend to set

Exam boards, job portals and government applications converge on a familiar set of caps, usually with dimension rules alongside the byte limit:

  • Passport-style photograph: commonly 20 KB to 50 KB, sometimes with a minimum size as well as a maximum.
  • Scanned signature: commonly 10 KB to 20 KB, and usually wider than it is tall.
  • Supporting documents and certificates: commonly 100 KB to 500 KB.

Treat those as the shape of the problem, not the rule for your form. The instructions on the page you are uploading to are the only figures that count, and many portals also impose a minimum file size or fixed pixel dimensions that a byte target alone will not satisfy.

When the result still looks bad

If the output is legible but ugly, the usual cause is that too many pixels are sharing too few bytes. Three things help, in order of how much they buy you:

  • Crop before you compress. A passport photo needs head and shoulders, not the room behind you. The crop tool cuts the pixel count so every remaining byte goes to the part that matters.
  • Choose the dimensions yourself with the image resizer before compressing, rather than letting the search pick them. If you know the form wants 200x230, resize to it first.
  • Switch to WebP if the portal accepts it, for a meaningful gain at no visual cost.

If you have no specific number to hit and simply want the file smaller, the plain image compressor is the better fit - it optimises for quality per byte instead of chasing a cap.

Why this runs in your browser

The images that come with a byte limit attached are rarely trivial ones. They are passport photographs, scanned signatures and identity documents - precisely the material worth not handing to an unfamiliar server. Every step here happens on your own device using the browser's canvas: the file is read locally, re-encoded locally, and the download comes from memory. Nothing is uploaded, and no copy is left on anyone else's disk.

Open the Compress Image to Size tool, set your limit, and let it find the quality that fits.

Frequently asked questions

How do I compress an image to exactly 20 KB?
Set 20 as the target and let the tool search - but understand that "exactly" is not what you want. Byte limits are maximums, so the goal is the largest file that still fits under 20,480 bytes, which is what the search finds. Landing at 19.9 KB is a better result than 20.0 KB, not a worse one, because it satisfies the rule with a margin. On a phone photo a 20 KB cap will almost certainly require reducing the dimensions as well as the quality; leave the shrink option ticked or the target may be unreachable. If the portal counts a kilobyte as 1,000 bytes rather than 1,024, aim at 19 KB to stay clear of the discrepancy.
Does compressing to a size limit reduce the resolution?
Only when it has to. The search always tries quality first and keeps your original dimensions if any quality setting produces a file under the limit. It reduces the pixel dimensions only when even the lowest quality is still too big - a 12-megapixel photo squeezed into 20 KB, for instance, where no quality setting can get there and holding the resolution would just produce an unrecognisable image. The result panel always reports the final dimensions and whether they changed, and you can prevent resizing entirely by unticking the option, in which case an unreachable target is reported rather than silently missed.
Why is my file rejected even though it is under the limit?
Three common causes beyond the byte count. The portal may compute kilobytes as 1,000 bytes, making its real cap about 2.4 per cent tighter than yours - drop the target a kilobyte or two. It may enforce pixel dimensions or an aspect ratio as well as a file size, which a byte target alone will not satisfy; resize or crop to the stated dimensions first. Or it may accept only specific formats, typically JPG and sometimes PNG - a WebP file will be refused on format grounds no matter how small it is, so switch the output to JPG unless the instructions say otherwise. A few forms also set a minimum size, rejecting files that are too small.