Compress image to size

Type the size limit of your form or portal, in KB or MB, and get a JPG or WebP that fits. The page tells you whether it cut quality or pixels. Your pictures stay in your browser.

Compress image to size

How to compress an image to a size

  1. Add your pictures: drag JPG, PNG, WebP or AVIF files onto the box above or click to browse.
  2. Type the Target size, for example 100, and choose KB or MB. If your form counts 1 KB as 1,000 bytes, type a little less.
  3. Choose the Output format: JPG for forms, WebP for smaller files that not every form takes.
  4. Click Compress to this size and read the note under each result. It says the quality used, or that the picture was also made smaller.
  5. Download each file, or click Download all as ZIP. Names carry the target, such as photo-100kb.jpg.

What this tool does

Forms and portals often refuse a picture over a size limit. You type the limit, add your pictures, and the tool gives back a copy that fits. It works for "compress image to 100KB" and for "resize image to 100KB" alike, because both mean the file size in bytes, not the width and height. Pixel dimensions are the job of the image resizer.

Three settings control the result. Target size is a number from 1 to 100,000 and starts at 200. Unit is KB or MB. Output format is JPG (the default) or WebP. A KB is 1,024 bytes and an MB is 1,048,576 bytes. The tool tries the highest quality that fits, from 95 down to 30. If even quality 30 is too big, it also makes the picture smaller and searches again. A note under each result says which one it changed.

Nothing leaves your browser. To check, we opened the page in a test browser, added a photo and recorded all network traffic: 20 requests, no request carried data, and the hosts outside GramFile were Google's ad and analytics services, which load on every GramFile page, and jsDelivr (the codecs). The codec files download from jsDelivr (no hash check), only once a picture is added. We tested Chromium alone. Results are named after the original with the target added, so photo.jpg at 100 KB becomes photo-100kb.jpg.

What happened at each target

Our test photo is a 1280 by 960 JPG of 247,358 bytes. The default 200 KB target gave 198,889 bytes at quality 90. A 100 KB target gave 96,731 bytes at quality 88 and the full 1280 by 960 pixels. For 50 KB the tool needed quality 81, and for 20 KB quality 67, still at full size. The table on this page has every run. One conversion took about two seconds.

Below that, quality alone ran out. The 8 KB result was 8,095 bytes and the picture was made smaller, 1009 by 756 pixels. A 4 KB target gave 555 by 416, and the 1 KB minimum gave 126 by 95, which is a thumbnail. Read the note under the result: it tells you the pixel size when the picture was shrunk, and some forms also set a minimum size.

The samples are synthetic, not camera photos. Real photos will need different qualities to hit the same targets.

Why the result is rarely exactly the target

The tool picks the highest quality that stays at or under the target, in whole steps, so the file lands just below the limit and not on it. On our photo the results ranged from 74 to 99.5 percent of the target: 96,731 against 102,400, then 50,919 against 51,200. The low case was 150 KB, where quality 89 gave 113,448 bytes and the next step up, quality 90, would have been over the limit. The tool never goes over, and every result we read back was within its target.

It also never pads a file up to the target. Quality stops at 95. Our PNG photo with a 150 KB target and WebP output came out at 54,648 bytes, 36 percent of the target, because quality 95 already fit. A picture that is already smaller than the target is not touched. At a 1 MB target our 247,358 byte JPG came back byte for byte identical in 85 milliseconds, with the note that it was already under the target size.

KB, kilobytes and what your form counts

This tool counts 1 KB as 1,024 bytes, the way Windows does and the way many upload forms do. Some forms count 1 KB as 1,000 bytes. If yours does, a 100 KB target can give a file up to 102,400 bytes, which is over the limit. Our 50 KB run shows the risk: it produced 50,919 bytes, under 51,200 but over 50,000. When a form is strict, enter a target about 5 percent lower, such as 95 for 100.

JPG, WebP and PNG

JPG is the default because almost every form accepts it. WebP keeps more quality at the same size, but not every form takes it. On our photo, a 100 KB target gave 81,530 bytes as WebP and 96,731 as JPG. At 8 KB, WebP kept 1142 by 856 pixels and JPG had to drop to 1009 by 756. Output is only JPG or WebP. There is no PNG output, because PNG is lossless and cannot be squeezed to an exact size.

PNG files are accepted as input. Our 620,844 byte PNG photo became 97,018 bytes as a JPG at a 100 KB target, with quality 94. For "compress PNG to 100KB" this is the route: the result is a JPG, not a PNG.

Transparency costs bytes. Our transparent logo (21,105 bytes) became a JPG at 10 KB with its transparent area turned white, at full size 600 by 600. As WebP the transparency stayed, but the tool had to shrink the logo to 286 by 286 to reach the same 10 KB. For a logo on a plain background, JPG fits better.

What is removed and one thing that is not

When the tool re-encodes a picture, camera details, date, location and colour profile are dropped, and a picture stored sideways is turned upright. Our photo with a rotation flag came out 1280 by 960 at 20 KB. We did not test a Display P3 photo.

A picture that is already under the target is returned untouched, and that includes its metadata. We gave the tool a JPG with EXIF data and a 1 MB target. The file came back identical, with the camera make still inside it. If you want metadata removed, set a target below the file's size so it is re-encoded. The page states the removal in the note only on files that were compressed.

The under-target check looks at size only. A 24-byte text file named .jpg, with a 50 KB target, came back as it was and the page said it was under the target. A larger fake file failed with "this is not an image this tool can read." So a returned file is not proof the picture is valid. Open it before you upload.

Limits and what we did not test

You can add up to 50 files, each up to 100 MB, and they all share one target. A 51st file is refused with "Only 50 files at a time." Fifty copies of our photo at 100 KB took 85.7 seconds, about 1.7 seconds each, because every file needs several trial encodes. We read back six of the results and all were under 102,400 bytes. A target of 0 or 0.5 KB fails with "Enter a target of at least 1 KB."

GIF and HEIC files are refused with "this file type is not supported here." Convert iPhone photos with HEIC to JPG first. An animated WebP comes out as one still image: at 5 KB ours became a single 156 by 156 picture. In the code, a picture that would have to fall below 32 pixels on a side is refused with a message to choose a larger target, but we did not trigger that. We did not test files near 100 MB or other browsers.

Common jobs

A photo for an application form. Type the limit, use JPG, and check the pixel size in the note. Quality you choose, not a size. Use the image compressor. Exact width and height. Use the image resizer. Several pictures in one PDF. Make them small here, then use image to PDF. A PDF that is too big. Use the PDF compressor. To change only the format, see the image format converter, or browse the image tools.

Measured results

One 247,358 byte JPG photo at several targets, headless Chromium. Pixel difference is the average change from the original on a scale of 0 to 255.
TargetResult bytesShare of targetWhat changedPixel sizePixel difference
200 KB (default)198,88997 percentQuality 901280 by 9600.92
150 KB113,44874 percentQuality 891280 by 9601.49
100 KB96,73194 percentQuality 881280 by 9601.58
50 KB50,91999 percentQuality 811280 by 9601.79
20 KB20,33799 percentQuality 671280 by 9601.99
8 KB8,09599 percentQuality 30 and smaller picture1009 by 7562.38
4 KB4,05399 percentQuality 30 and smaller picture555 by 4162.39
1 KB1,01299 percentQuality 30 and smaller picture126 by 954.4

Prefer desktop software?

Use a desktop image program when you need exact pixel dimensions and a size limit together, want to compare quality side by side, or must keep camera and date data. This page cannot preview the result, and it applies one target to every file.

GramFile has download pages for IrfanView and XnView MP.

Frequently asked questions

Are my pictures uploaded?

No. Your browser does the work. A request log of our test showed 20 requests, none with data in it, and the outside hosts were Google's ad and analytics services and jsDelivr (the codecs). The codecs now come from jsDelivr.

Will the file be exactly 100 KB?

No. It will be at most the target, and close below it. In our runs the result was between 74 and 99.5 percent of the target. A 100 KB target gave 96,731 bytes.

Is a KB 1,000 or 1,024 bytes?

1,024 here, the way Windows counts and many upload forms do. If your form uses 1,000, enter a target about 5 percent lower, because 50 KB gave us 50,919 bytes.

Will I lose quality?

Yes, a little at modest targets and a lot at small ones. At 100 KB our photo kept all its pixels at quality 88. At 8 KB it was also made smaller. The note tells you which.

How do I compress a PNG to 100 KB?

Add the PNG and choose JPG or WebP. Our 620,844 byte PNG became 97,018 bytes as JPG. The output is not a PNG.

What if my image is already under the target?

You get it back unchanged, with its metadata. Set a lower target if you want it re-encoded.

Can it keep transparency?

Only as WebP. JPG turns transparent areas white. Our transparent logo had to be shrunk to 286 by 286 as WebP to reach 10 KB.

Why is my picture smaller in pixels?

Quality alone could not reach your target, so the tool also reduced the pixels. At 8 KB our photo went from 1280 by 960 to 1009 by 756.

How many files can I do at once?

Up to 50, each up to 100 MB, all with one target. Fifty took 85.7 seconds in our test.