The form says your photo is too big

You have the photo. You have the form. The form says "File must be under 20 KB" and your phone gave you a 2.4 MB JPG.

This happens on exam portals, job applications, visa forms and university admissions every day. The usual fix is to search "compress image", upload the photo to a random site, and hope. That works, but it sends a photo of your face to a server you know nothing about, and it often misses the limit anyway.

This post explains what is actually going on with file size, how to hit an exact KB limit, and how to do it entirely in the browser. There is a short JavaScript example at the end if you want to build it yourself.

Why forms set KB limits

Portals that take thousands of applications a day store every photo and signature. Small, predictable files keep storage and page loads cheap, so they set a maximum.

Many also set a minimum. A file that is too small is usually blurry or blank, so the portal rejects it. That is why you see ranges such as:

  • Photo: 20 KB to 50 KB
  • Signature: 10 KB to 20 KB
  • Scanned document: up to 300 KB

Most also fix the pixel size or the aspect ratio, and many ask for JPG only. Read all three rules (size, dimensions, format) before you start. Missing any one of them gets the upload rejected.

Pixels and kilobytes are different things

Pixels are the image's width and height. Kilobytes are how much space the file takes. They are linked, but not tightly.

A JPG's size depends on three things:

  1. Dimensions. A 4000 × 3000 photo has 12 million pixels. A 300 × 400 photo has 120,000. Fewer pixels, smaller file.
  2. Quality setting. JPG throws away detail you are unlikely to notice. Lower quality throws away more, so the file shrinks.
  3. Content. A plain wall compresses far better than grass, hair or a patterned shirt. Two photos with the same pixels and quality can differ in size several times over.

That third point is why "resize to 300 × 400" alone often fails. The dimensions are right but the file is still 60 KB, because the photo is busy or saved at high quality. You need to control quality as well.

Step by step: crop, resize, then compress

Do it in this order. Each step makes the next one easier.

  1. Crop first. Cut away background so the face or signature fills the frame. Less background means more of the limit goes on detail that matters.
  2. Resize to the required pixels. If the form says 300 × 400, set exactly that. If it gives only a size limit, about 400 to 600 pixels on the long side is plenty for an ID photo.
  3. Compress to the target size. Lower JPG quality step by step until the file is just under the limit. Aim for 1 to 2 KB under, not 10 KB under, so you keep as much detail as possible.
  4. If quality gets too low, shrink the pixels a little and try again. A sharp 250 × 330 photo looks better than a blocky 300 × 400 one.

Step 3 is the fiddly part by hand. In code it is a short binary search on the quality value. This runs in any modern browser, and the image never leaves the device:

// Compress an <img> or ImageBitmap to a JPG at or under maxKB. async function compressToKB(source, width, height, maxKB) { const canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; const ctx = canvas.getContext('2d'); ctx.fillStyle = '#fff'; // JPG has no transparency ctx.fillRect(0, 0, width, height); ctx.drawImage(source, 0, 0, width, height); const limit = maxKB * 1024; const encode = q => new Promise(r => canvas.toBlob(r, 'image/jpeg', q)); let lo = 0.05, hi = 0.95, best = null; for (let i = 0; i < 8; i++) { // 8 rounds is enough precision const q = (lo + hi) / 2; const blob = await encode(q); if (blob.size <= limit) { best = blob; lo = q; } // fits: try higher quality else { hi = q; } // too big: go lower } return best; // null means even the lowest quality is too big: shrink the pixels } 

If it returns null, scale the width and height down by about 15% and call it again. Some portals count 1 KB as 1,000 bytes rather than 1,024, so maxKB * 1000 is the safer limit if you are close.

Check the result before you upload

Don't trust the name of the file. Check the actual size and dimensions.

Device How to see the file size and pixels
Windows Right-click the file → Properties. Size is on the General tab, pixels on the Details tab
Mac Select the file and press Cmd + I. Size and dimensions are under General and More Info
Android Open it in Files or Gallery → the ⓘ or Details option
iPhone Open it in Photos and swipe up, or use Files → Get Info

Two things to look for: the size is under the limit (and over the minimum, if there is one), and the format is JPG. A file renamed from .png to .jpg is still a PNG inside, and some portals detect that.

When it still won't go through

  • Too small, not too big. If the form wants at least 20 KB and you have 14 KB, raise the quality or use a slightly larger pixel size. A file can also be padded with metadata the image ignores, which some tools do for you.
  • Signature looks faint. Sign in black ink on plain white paper, photograph it in daylight, then crop tight. Faint grey strokes get lost at low quality.
  • Upload button does nothing. Check the format. HEIC photos from iPhones need converting to JPG first.
  • Photo rejected for the background. That is a separate rule from size. Many ID photos need a plain white or light background.

The short version

Crop, set the pixels, then lower JPG quality until the file is just under the limit. Check size, pixels and format before you upload.

If you would rather not write the code, I built a free tool that does this in the browser, with presets for common limits: resize image to 20KB. Nothing is uploaded, and there is no sign-up.

What limits have you run into? Share the strangest one in the comments.