utilduck
Home · Office · Image Compressor to KB

Image Compressor to KB

Pick a target size (or enter your own KB), and this tool finds the JPEG quality that fits under it automatically.

100% local processing — your photo is compressed in your browser using canvas and is never uploaded anywhere.

How does compressing an image to an exact KB work?

This tool re-encodes your photo as JPEG and repeatedly tests different quality levels using binary search until it finds the highest quality that still fits under your chosen KB target, all inside your browser. Many official online forms — university admissions, government ID uploads, exam applications — reject photos over a strict KB limit, and manually dragging a quality slider until the file happens to be small enough is slow and imprecise.

If your photo cannot reach the target at any JPEG quality (common with very small targets like 20KB on a large photo), the tool automatically shrinks the image dimensions in steps and retries the quality search, since a smaller photo compresses further than a lower-quality large one. Any transparent background is filled white first, since JPEG does not support transparency.

How do I compress a photo to exactly 20KB, 50KB, 100KB or 200KB?

Pick a target size, then the tool re-encodes your photo as JPEG and uses binary search on the quality setting (0-100%) to find the highest quality whose file size still fits at or under your target, downloading the result automatically. Example: a 2MB phone photo targeting 50KB might land at quality 34% and 48.7KB — well under the limit while keeping as much detail as that size allows.

Steps to compress an image to a target KB

  1. Drag your photo onto the drop zone, or click it to choose a file from your device.
  2. Pick a preset target (20KB, 50KB, 100KB, 200KB) or type your own value in the custom KB field.
  3. Press Compress & Download; the tool tests JPEG quality levels with binary search, each time checking the resulting file size against your target.
  4. If even the lowest quality is still too large at full resolution, the tool automatically shrinks the image dimensions and repeats the quality search at the smaller size.
  5. Review the achieved size and pixel dimensions shown, then use the download link — the file is already saved as a .jpg.

How the binary search finds the right quality

At each step: try quality = (low + high) / 2 -> encode -> if resulting bytes <= target, raise the floor (low = mid); otherwise lower the ceiling (high = mid). Repeat ~10 times, then use the highest quality that still fit.
  • Quality = the JPEG encoder setting from 0 (smallest, most artifacts) to 100 (largest, least loss) passed to the browser's canvas.toDataURL()
  • Target bytes = your chosen KB x 1024, since 1 KB = 1024 bytes in file-size terms used by canvas and most upload systems

Typical results by target size

TargetTypical outcomeCommon use
20 KBUsually needs both reduced quality and reduced dimensions for a normal photoIndia SSC/UPSC/PAN card photo uploads
50 KBOften reachable by quality reduction alone on a moderately sized photoID and document photo uploads
100 KBComfortable for most passport-style photos at good qualityGeneral form and profile photo uploads
200 KBUsually keeps visibly good quality even on larger photosIndonesia CPNS and similar application uploads

Frequently asked questions

Why can't my photo always hit an exact KB number like exactly 50.0KB?

JPEG quality settings only take whole percentage steps and the resulting file size depends on image content, so the binary search finds the closest quality level whose output is at or under your target — usually within a fraction of a KB — rather than landing on an exact byte count.

Why does the tool sometimes shrink my photo's dimensions instead of just lowering quality further?

Very small targets like 20KB often cannot be reached at any JPEG quality for a large, detailed photo because JPEG has a practical floor below which quality collapses into unusable blocky artifacts; reducing the pixel dimensions first, then compressing, produces a smaller and cleaner result than pushing quality to its unusable minimum.

Is this the same as the KB limits required by government forms like India's SSC or UPSC?

This tool targets the exact KB numbers those forms commonly require (20KB, 50KB, 100KB, 200KB), but always check the specific form's exact requirements — some also specify minimum/maximum pixel dimensions or file format beyond just file size, which this tool does not verify.

Is my photo uploaded to a server during compression?

No. Everything runs with your browser's built-in canvas API — the file is read locally, redrawn to an in-memory canvas, and re-encoded, all without any network request.

This tool only outputs JPEG, since JPEG's adjustable quality makes hitting a KB target possible; it does not verify pixel-dimension or format rules that some official forms require beyond file size, and results depend on your browser's JPEG encoder, which can vary slightly between browsers.