Compress Image to Target Size

Compress JPG, PNG and WebP images down to a target KB size. The tool resizes to your max edge first, then binary-searches the best JPEG quality, all locally in your browser.

Click to select or drag an image here JPG, PNG, WebP up to 30MB each. Output is always JPG

100 KB by default. Allowed range is 5 to 20000 KB.

The long edge shrinks to this many pixels before quality is searched.

How to use

  1. Drag an image into the dashed box, or click it to pick a JPG, PNG or WebP file up to 30MB.
  2. Type the KB value you need in Target size. The default is 100 KB.
  3. Set Max edge when the pixel size matters too. Leave it empty to keep the original dimensions.
  4. The tool resizes once, then re-encodes at several qualities to find the best one under your target.
  5. Check the sizes, the size change, the dimensions and the preview, then click Download compressed image.

FAQ

Does hitting the target size hurt quality?
JPEG trades detail for bytes, so a smaller target means a lower quality setting. The tool keeps the highest quality that fits, yet a very small target still looks soft. Raise the target KB, or shrink the dimensions first, when quality matters.
Why is the output always JPG?
At the same quality setting, JPG is usually the smallest of the common formats, which suits hard file size limits. Transparent PNG files get a white background first. Convert to PNG or WebP instead when you need to keep transparency.
I asked for 100 KB and got 97 KB. Is that normal?
Yes. Quality is a discrete scale, so the best match usually lands a little under the target. The tool will not push quality back up to fill the gap, since that could break the limit.
Is my image uploaded anywhere?
No. Resizing, test encodes and the final JPEG all run in your browser on a Canvas. The file never leaves your device, which is fine for ID photos and scanned contracts.

How to use

  1. Pick the image and target

    Drop a JPG, PNG or WebP file into the dashed box, or click it to browse. Then type the file size you need in Target size, for example 100 KB.

  2. Wait for the trial encodes

    The tool starts at once and the progress bar counts each trial encode. Every trial re-encodes the whole JPEG, so a large photo takes a few seconds.

  3. Read the result panel

    The panel lists the original size, the compressed size, the size change, the dimensions and the quality used. A green note means the target was met.

  4. Download or adjust

    Click Download compressed image once the result looks right. The file is named after the original with -compressed.jpg added to the end.

About this tool

Many upload forms cap image size. Job portals, exam registrations and store backends often demand 100 KB or 200 KB, and anything larger is rejected outright. Most compressors ask you to drag a quality slider and hope for the best, so people export, check the byte count, and try again. This tool turns the problem around. You enter the target size, and the page finds the highest JPEG quality that still fits. Resolution goes into the Max edge field and volume goes into the target value, which keeps both limits under your control.

Everything runs in the browser, so the image never leaves your device. The tool draws the picture on a Canvas at the chosen edge length and fills a white background. Then it binary-searches the JPEG quality between 0.05 and 0.95. Each trial is a real encode with a real byte count, about eight in total. The search keeps the highest quality that fits the target. When even quality 0.05 is too large, the page says so, reports the smallest file it produced, and suggests a smaller edge length. A wrong success message would be worse than a clear failure.

How it works

JPEG splits a picture into 8 by 8 blocks, transforms each block, and quantizes the coefficients. The quality value sets the quantization step. A larger step throws away more high-frequency detail and yields a smaller file. At a fixed pixel size, the byte count rises with quality, and that monotonic relation is what makes binary search valid. Each step encodes the image once at the midpoint of the current range. A file over the target lowers the upper bound, and a file under it raises the lower bound. Seven steps come close to the best quality available.

File size grows with the number of pixels. Halving the long edge leaves about a quarter of the data at the same quality. That is why the suggestion uses an area ratio to estimate a new edge length. Quality alone cannot shrink a file without limit, since JPEG encoders barely respond below 0.05. A detailed photo with a 20 KB target will not fit by quality alone, and shrinking the canvas is the only real lever. The tool states that plainly, names the smallest size it reached, and offers a smaller edge to try. Honest numbers let you weigh a softer picture against a bigger upload limit.

When to use it

  1. Forms and job portals

    Exam registrations and hiring systems often cap attachments at 100 KB or 200 KB and reject anything larger. Drop in a phone photo, type 100, and a few seconds later you have a JPEG that passes the check. Dimensions and quality are settled in the same pass, so no second tool is needed.

  2. Store and CMS images

    Product shots, article headers and profile pictures usually have a size cap, yet they still need to look sharp. Set Max edge to the display width, then set the target KB. The search runs at that exact size, which avoids the double compression that happens when a platform shrinks an already compressed file.

  3. Email and portal uploads

    Mail attachments and government forms limit the total message size, and scanned pages blow past it fast. Compress each page to 100 KB before packing them, which keeps the text readable and avoids the bounce that a single oversized message causes.

Tips & tricks

  • Set Max edge before you lower quality. Cutting pixels usually saves more bytes than a soft, blurry encode.
  • For a very small target, an edge of 1000 px or less works better than pushing quality to its floor.
  • The result refreshes after each edit, so you can change the KB value without picking the file again.

Things to watch

  • Tiny targets blur

    Push a 4000 px photo down to 20 KB and text edges start showing blocks and colour fringes. Lowering the edge length works much better than crushing quality further, because fewer pixels leave more bits for the fine detail that remains.

  • Transparency turns white

    The output is always JPG, which has no alpha channel. Transparent areas of a PNG get a white background first, so an icon that looked fine on a dark page can show a pale halo. Convert to WebP or PNG when you need transparency.

  • A miss is still a miss

    When quality 0.05 is over the target, the warning gives the real size and suggests a smaller edge. That file is still too large for most upload forms, so do not download it and hope. Shrink the edge or raise the target KB, then run it again.

Related Tools