BlogImage Compression

Compress Image to Exact Size: 100KB, 500KB, 1MB, or 2MB

Learn how to compress an image under 100KB, 500KB, 1MB, or 2MB by adjusting dimensions, format, and quality, with safe starting settings and verification steps.

Updated: June 17, 2026

You usually cannot guarantee a byte-exact result — the practical goal is the largest acceptable image that stays slightly under the limit. To compress an image to 100KB, 500KB, 1MB, or 2MB, resize the image to the required pixel dimensions first, choose JPEG or WebP for photos, lower quality in small steps, then verify the final file size before uploading. For very small targets such as 100KB, reduce dimensions first; for larger targets such as 1MB or 2MB, preserve more pixels and tune quality last. Always keep a few KB of headroom, because no JPEG or WebP encoder produces a file to the exact byte.

Key Takeaways

  • "Exact size" means safely under the limit. Encoders are approximate — target a few KB below the cap, not byte-for-byte.
  • Two levers, not one. Lowering quality alone will not reach 100KB if the image is still 6000px wide — shrink dimensions first, then tune quality.
  • Match format to goal. WebP for the smallest photos (Google's study: 25–34% smaller than JPEG at equivalent SSIM quality), JPEG for maximum compatibility, PNG for graphics and transparency only.
  • CLI tools can automate the loop. jpegoptim --size=500k file.jpg iterates quality automatically for JPEG; for PNG, use pngquant to reduce size, then verify and iterate.
  • Always compress from the original. Re-saving an already-compressed JPEG causes generation loss and makes size targeting harder.
  • Leave headroom. Aim for about 95–98% of the limit (e.g., ≈95–98KB for a 100KB cap; ≈475–490KB for 500KB; ≈950KB for 1MB; ≈1.9MB for 2MB).

Common Upload Limits That Require a Smaller Image

Hard file-size limits are everywhere. The examples below are common references — always verify the specific rules for your destination, since limits vary by country, application type, and platform:

DestinationCommon example limitNotes
Passport / visa photo uploadOften 50–240KBVaries widely; U.S. visa requires JPEG, square, 600×600–1200×1200 px, sRGB (verify at travel.state.gov)
Government / immigration portalsOften 2MB per documentCanada IRCC notes some applications cap at 2MB (verify at ircc.canada.ca)
Personal email attachments~25MB total per messageGmail and Outlook.com personal accounts commonly use 25MB; work/school accounts and receiving mail servers may differ
CMS / blog featured images1–2MBKeeps page weight and Core Web Vitals reasonable
Avatars and profile photos50–500KBSquare crops, often 512×512 or smaller

When a portal rejects a file for being 1KB over, "compress it a bit" is not enough — you need a repeatable way to land under a number.

The Core Method: A Quality-and-Dimensions Loop

File size is roughly a function of three things: pixel count, encoding quality, and format efficiency. To hit a target, reduce one or more of them and then measure:

  1. Set the pixel dimensions the destination requires (or the largest size you can afford to use).
  2. Pick the format — WebP if the portal accepts it, otherwise JPEG for photos.
  3. Choose a starting quality level and export (see the cheat sheet below).
  4. Read the resulting file size. If it is over target, lower quality by 5–10 points or reduce dimensions by ~20%, and export again.
  5. Stop at the highest quality that keeps the file under the limit.

A useful rule of thumb: drop dimensions first, quality second. An image at the right pixel size and quality 75 almost always looks better than an oversized image crushed to quality 30.

Many target-size compressors use an iterative or binary-search-like quality loop internally, so doing it by hand with a slider is the same process — just with your eyes on the result.

Three Ways to Compress an Image Under a Target Size

Option 1: Browser compressor (fastest, visual)

A browser-based compressor is the simplest path when you want to see the result before saving.

  1. Open a local image compressor in your browser.
  2. Set the output format (WebP or JPEG for photos).
  3. Reduce the pixel dimensions to what the destination needs.
  4. Move the quality slider down in steps and watch the reported file size.
  5. Download once the size reads safely under your target.

For private files, LessMB runs its image compressor entirely in your browser with no server upload, so the photo never leaves your device. You can adjust format, quality, and pixel dimensions until the output sits under your target. LessMB supports JPG/JPEG, PNG, SVG, GIF, WebP, AVIF, and JXL — which covers common web image formats, but you should still check the upload form's accepted formats before converting.

Option 2: Command line (repeatable, scriptable)

If you compress many images or want to hit a target automatically, the CLI is the most precise tool available.

Hit a JPEG target size in one command with jpegoptim:

jpegoptim --size=100k photo.jpg      # aims for ≈100KB
jpegoptim --size=500k photo.jpg      # aims for ≈500KB
jpegoptim --size=2000k photo.jpg     # aims for ≈2MB

jpegoptim --size iterates JPEG quality until the file reaches the target — the closest automated approach to exact-size compression for JPEG files.

Loop over quality with ImageMagick when you also need to resize:

for q in 85 75 65 55 45; do
  magick input.jpg -resize 1600x1600> -quality $q out-q$q.jpg
done
# then pick the highest q whose file is still under your limit

Reduce PNG size with pngquant (lossy palette reduction, keeps transparency):

pngquant --quality=60-80 --output out.png --force image.png

Note: pngquant compresses by reducing the color palette to a quality range — it does not guarantee a specific file size. After running it, check the output size and iterate (try a lower quality range or crop the image) if the file is still too large.

These tools are free, run offline, and can batch many files with the same settings.

Option 3: Desktop editor (most control over crop and detail)

In GIMP, Photoshop, or Affinity Photo, use Export As (not Save), choose JPEG or WebP, and adjust the quality slider. Many desktop editors show an estimated export size or let you preview the result before saving, though the estimate accuracy varies by app version and format. Desktop editors are useful when you also need to crop, retouch, or meet both a pixel-dimension requirement and a file-size limit simultaneously.

Which Method Should You Use?

SituationBest method
One-off private image (ID, passport, form upload)Browser compressor such as LessMB — local processing, no upload
Batch JPEG files, need to hit a target automaticallyjpegoptim --size= on the command line
PNG with transparency, need to reduce sizepngquant to reduce, then verify and iterate
Need to crop, retouch, or match pixel dimensions preciselyDesktop editor (GIMP, Photoshop, Affinity Photo)
Unknown portal format requirementsJPEG first (widest compatibility), then verify accepted formats

Target-Size Starting Points

Use these as starting points only — actual output size depends on image content, noise, color complexity, embedded metadata, and format. Adjust quality up or down after your first export.

TargetTypical use caseStart quality (JPEG)Start long-sideBest format
100KBPassport / application photo, avatar, thumbnail60–65600–800pxJPEG
500KBEmail attachment, form upload, social preview70–801200–1600pxJPEG / WebP
1MBBlog hero, product image, featured image80–851920–2400pxWebP / JPEG
2MBHigh-res scan, large gallery, print-ready web88–923000–4000pxJPEG

If you can use WebP, drop the starting quality roughly 5–8 points below the JPEG value — WebP holds detail better at lower settings, which is why it typically produces a smaller file at the same visual quality.

Headroom rule: Aim about 2–5% below the cap to avoid rejection from rounding or metadata:

LimitSafe target
100KB95–98KB
500KB475–490KB
1MB~950KB
2MB~1.9MB

JPG vs PNG vs WebP: Which Format Hits the Target Easiest

Format choice changes how hard it is to reach a size:

  • WebP — smallest for photos. Google's WebP compression study found lossy WebP averaged 25–34% smaller than JPEG at equivalent SSIM quality. Use it whenever the destination portal accepts WebP.
  • JPEG (JPG) — the compatibility default. Every form, browser, and device reads JPEG, and its quality slider is the most predictable size lever. Use it as the fallback for uploads to unknown portals.
  • PNG — lossless and supports transparency, but for photographic content it is almost always larger than JPEG. PNG is the wrong choice for hitting a small KB target on photos. Use PNG for logos, screenshots with text, or anything requiring transparency.
  • AVIF / JXL — newer formats that can be smaller than WebP, but upload portal support is still limited. Check the destination's accepted formats before relying on them.

The practical takeaway: for a 100KB photo target, JPEG or WebP will get you there; PNG likely will not.

Common Mistakes (and How to Fix Them)

  • Lowering quality without resizing first. A 6000px-wide photo can still be too large regardless of image content, even at very low quality. Reduce dimensions to what the destination actually displays first.
  • Re-compressing an already-compressed JPEG. Each lossy save adds artifacts. Always go back to the original file when targeting a size.
  • Forcing a photo into PNG to "save space." PNG is lossless and tends to be larger for photos — the opposite of what you need.
  • Aiming for the exact limit byte-for-byte. Re-encoding or added metadata can nudge a file over the cap. Leave 3–5% headroom.
  • Ignoring accepted formats. Some government and banking portals reject WebP or AVIF even though they produce smaller files. Confirm accepted formats before converting.

Troubleshooting: File Still Too Large

If the file is still over the limit after reducing quality, work through this list:

  • Strip metadata. EXIF, GPS, and ICC profile data can add tens of KB. Many export dialogs have a "strip metadata" option.
  • Crop empty backgrounds. Solid white or transparent borders contain data and increase file size — crop them out.
  • Resize more aggressively. If you are at quality 50 and still over target, dimensions are likely still too large.
  • Switch from PNG to JPEG or WebP. For photographic content, this is usually the single biggest size reduction.
  • Avoid nested compression. If you started from an already-compressed file, go back to the original before re-exporting.

Verification Checklist

Before you submit or publish the compressed file:

  • File size is under the limit, not equal to it (aim for the headroom targets above).
  • Pixel dimensions fall within the portal's minimum and maximum range.
  • Format is on the destination's accepted list.
  • Open the result at 100% zoom — no obvious banding, blocking, or blur in important areas (faces, text).
  • Original file is still saved separately for future re-export.

FAQ

How do I compress an image to exactly 100KB?

Reduce the pixel dimensions to roughly 600–800px on the long side, export as JPEG at quality 60–65, and check the file size. If it is over 100KB, drop quality in steps of 5–10 (or trim dimensions by about 20%) and export again. On the command line, jpegoptim --size=100k photo.jpg does this automatically for JPEG files.

Can I hit a file size to the exact byte?

No. JPEG and WebP encoders are not byte-exact, so the output is always approximate and can shift with metadata changes. Target a few KB below the limit — aim for about 95–98% of the cap — and treat "exactly 100KB" as "safely under 100KB."

Which image format produces the smallest file for photos?

WebP — Google's WebP compression study found lossy WebP averaged 25–34% smaller than JPEG at equivalent SSIM quality. Use JPEG when the portal only accepts it, and PNG only for graphics or images needing transparency, since lossless PNG is usually larger than JPEG for photographic content.

Will compressing to 100KB ruin image quality?

It depends on the starting resolution. A correctly sized 600px passport photo can look clean at 100KB; a 4000px photo forced to 100KB will show blocking and blur. Match the resolution to the target size, not just the quality slider.

What settings should I start with for 500KB, 1MB, or 2MB?

For 500KB: JPEG quality 70–80 at 1200–1600px long side. For 1MB: quality 80–85 at 1920–2400px. For 2MB: quality 88–92 at 3000–4000px. These are starting points — adjust based on image content and complexity, and verify the final size before uploading.

Why is my compressed image still larger than the limit?

The most common causes: pixel dimensions are still too large (quality alone cannot compensate), the file format is PNG for a photographic image (switch to JPEG or WebP), large EXIF or ICC profile metadata is adding bulk, or there is unused background space to crop. Work through the Troubleshooting section above.

Is it safe to compress sensitive images online?

Prefer a tool that processes locally. LessMB runs image compression in your browser with no server upload, so private photos, ID scans, and documents stay on your device while you tune the size and quality.

Sources