Compress to KB
Hit a target file size in KB. Keeps dimensions when it can; explains format or scale changes on the result panel.
Compressing the photo is step one. Check the margin.
Before you spend time on listing images, check what the order actually earns you. The Profit calculator subtracts platform fees, shipping and packaging from the selling price.
Smallest target for this file is KB — our :1 limit.
Destination shortcuts
Email chip = practical per-photo headroom under common ~25 MB message caps — not “email’s limit is 5 MB”. Email guide. Destination chips set a KB target; see email and WhatsApp guides. Form caps: 100–200 KB.
Form / visa presets
Form / visa presets (50–250 KB) are common hard caps. For very low budgets, meet any required dimensions first, then quality-sweep — EXIF metadata can add a few bytes. Exact KB is best-effort under format constraints.
Advanced (optional)
Maximum size is a ceiling: the image is only shrunk to fit, never enlarged, and the KB search may shrink it further. Fixed size is an exact canvas: the output is exactly the width and height you enter, and the KB search never changes it. Either way the result panel reports each condition.
Up to 5. Only these settings are stored in this browser — never the image, its file name, a download link or an account.
Details — who it's for & how it works
For: anyone who needs a size budget (for example under 100 KB) rather than a single quality default.
How it works: upload → set KB target → compress → download.
Prefer a single balanced re-encode? Use the Image Compressor. Format change only? Try the WebP Converter.
Quick Answer
Compress to KB hits a target file size in KB for one PNG, JPG or WebP image. It first sweeps the encoder quality in the source format, keeps the original dimensions whenever it can, and only changes format or scales dimensions when the budget cannot be met at the source settings. The result panel reports the measured original size, output size, quality and any format or scale change as honest notes — there is no promised reduction and no exact-KB guarantee. The same Pillow encoders (JPEG, PNG and WebP) used by the Image Compressor power the sweep.
Measured samples: four real runs on our own files
These images are our own test files, generated by scripts/gen_kb_samples.py and served from /static/examples/. No visitor upload was used. Each output was measured in one offline run of this tool's encoder on 2026-11-21 (Pillow 12.3.0), and the test suite re-runs every row below, so a number that stops reproducing fails the build.
-
JPEG photo pressed toward 100 KB
Source: 900 × 720 JPEG, 214237 bytes (209.2 KB) · Target: 100 KB · keep original format on
Measured output: 86582 bytes (84.6 KB) · encoder quality 74 · same 900 × 720 pixels · still JPEG · target met
Searching encoder quality at the source size reached the budget, so there was no resize and no format change.
-
Flat-colour interface screenshot, already under target
Source: 900 × 600 PNG, 3258 bytes (3.2 KB) · Target: 15 KB · keep original format on
Measured output: 3258 bytes (3.2 KB) · lossless, the source bytes were kept · same 900 × 600 pixels · still PNG · target met
The file was already under the budget, so the tool kept the original bytes instead of encoding it again.
-
Transparent PNG that reached 25 KB through its palette
Source: 720 × 540 PNG, 40924 bytes (40.0 KB) · Target: 25 KB · keep original format on
Measured output: 7145 bytes (7.0 KB) · 256-colour palette · same 720 × 540 pixels · still PNG · transparency kept · target met
PNG has no quality knob, so the palette was the lever: 256 colours at full size, with the alpha channel kept.
-
1 KB was out of reach, and the tool reported the miss
Source: 720 × 540 PNG, 40924 bytes (40.0 KB) · Target: 1 KB · keep original format on
Measured output: 1049 bytes (1.0 KB) · encoder quality 10 · reduced to 303 × 227 pixels · converted to JPEG · transparency flattened onto white · target not met, best-effort file
The source format could not reach 1 KB even at the smallest size the search is allowed to try, so the search converted the format and still fell short. The result panel shows it as not met, and JPEG has no alpha, so the transparency was flattened onto white.
These are four single runs, not an average ratio. A different photo, target or format lands on a different size.
Compressing for the web
Image compression only matters in the context of a real page delivery budget. Chrome for Developers publishes the Lighthouse audits PageSpeed Insights actually run, and the two audits that touch images are stated independently:
- Efficiently encode images asks whether the file could have been smaller at the same rendered dimensions by using a more efficient format or encoder. Per the Chrome for Developers audit docs, the threshold is approximately 4 KiB of potential savings per image.
- Properly size images asks whether the rendered display size on the page is meaningfully smaller than the source's intrinsic pixel dimensions. The Lighthouse audit flags an image when the displayed pixel size is far smaller than the file's actual pixel size, regardless of compression level.
Compress to KB is for the case where a destination enforces a specific byte cap — an email attachment, a CMS upload form, a mobile push payload. It is not the same as targeting the Efficiently encode images audit, which judges the file against the format at the same rendered dimensions; a file that passes this tool's KB budget can still fail that audit if the dimensions are wrong for the layout, and a file that passes the audit can still fail this tool's budget if the budget is smaller than the encoder can hit. The two checks are independent and the page must address both to clear the image-delivery section of a Lighthouse run.
When this tool is the right tool
A destination explicitly asks for a size budget — "under 100 KB", "max 200 KB", "must fit a 4 MB email attachment". The source is already at the dimensions you want and only the bytes are too high, or the destination does not care about the dimensions. The result panel reports whether the budget was met and whether the tool changed format or scaled.
When this tool is the wrong tool
If the source has more pixels than the destination actually renders, resizing the canvas first is the right move — the Social Media Image Resizer covers documented social-platform sizes, and the OG Image Generator produces a 1200 by 630 PNG for share-card use cases. If the destination is fine with the source format and there is no byte budget, use the Image Compressor instead — it uses one balanced default per format and never changes format or dimensions. If the destination requires a different format, use the WebP Converter for a same-dimensions WebP.
Common mistakes with target-size compression
Five issues that come up most often when compressing to a byte budget. Each one is rooted in the encoder behaviour rather than in this specific tool.
- Treating the target as a guaranteed hit. The encoder sweeps quality in the source format first — a PNG keeps its format and only reduces its colour palette as far as the budget needs; the result panel says how far. If that still exceeds the budget, the tool reduces the canvas and searches the source format again, and only then considers another format. If even that cannot fit the budget, the result panel shows the smallest best-effort file and a "Could not reach N KB under the current constraints" note — that is honest reporting, not a bug. If the file you upload is already smaller than the target, nothing is encoded: the panel returns your original bytes untouched and reports met-target.
- Confusing "scaled to fit budget" with a deliberate resize. Compress to KB never upscales. It only reduces dimensions, and only when the encoder cannot hit the budget at full size — no smaller than a quarter of the source width and height. The result panel calls the change out explicitly so the user can decide whether to keep the smaller file or relax the budget. A user who wants a specific canvas size should use a resizer first (Social Media Image Resizer, Amazon / Shopify / Etsy Product Image Resizers), not rely on this tool's automatic downscale.
- Letting a PNG with transparency become a JPEG on white. When "Keep original format" is on and the budget cannot be met in PNG, the tool falls back to WebP lossy with alpha kept, or further to JPEG when even WebP does not fit. JPEG cannot carry transparency, so the result panel lists a "transparent pixels were flattened onto white" note when this happens. If transparency must survive, raise the budget, work from a smaller source image, or uncheck "Keep original format" to allow WebP-with-alpha to be picked earlier in the sweep.
- Running it on a source whose bytes are already below the target. A source at 60 KB with a 100 KB target does not need compression at all. The tool reports "Source already under target; kept original bytes" and returns the upload byte for byte, with no re-encode. The result panel is honest about this; do not treat the unchanged output as a tool bug.
- Reading "Could not reach X KB" as a failure. Some sources cannot be compressed to a tight budget without either making the image visibly worse than the source or scaling dimensions past a useful size. When that happens the panel shows the smallest file the encoders can produce and a note that the target was not met. Treat it as a signal to relax the budget, pick a different source, or accept the best-effort file as-is.
Check the output
Compress to KB can change format and dimensions to hit a budget. The result panel reports the measured original size, output size, format and dimensions; the four-point checklist below is the validation pass a responsible shipper runs once per output before uploading it anywhere.
- Dimensions. Confirm the output width and height match the destination display slot. Compression does not change dimensions by default; if the panel shows "Scaled to fit budget", the dimensions stepped down and the file may be smaller than you want for the layout. The Resize vs Compress guide covers the relationship between pixel count and byte count, and the Optimize Images for the Web guide covers when resizing the canvas is the right first step. Chrome for Developers' Properly size images Lighthouse audit flags images whose intrinsic dimensions far exceed the rendered slot.
- File size. Confirm the output bytes are at or below the target. The result panel reports met-target (green) or best-effort (amber) and the measured size. If the panel says best-effort and the file is still over the destination's documented limit, the encoders cannot reach a budget smaller than this file's compressed representation at the current size and format, so one of those three things has to change: raise the target when the destination allows it, turn off "Keep original format" to allow a more efficient format, or work from a smaller source image (for a large upload, the "Make a smaller copy" button under the file picker shrinks one on this device before it is sent). Do not enlarge the source to fix a byte limit: more pixels make a small target harder, and this tool never upscales. Where the destination fixes exact pixel dimensions, keep them and loosen the budget instead; reduce dimensions only where the destination publishes a maximum or says nothing about size. Converting a transparent PNG can cost transparency, since WebP carries alpha and JPEG does not, so re-check the output on the real destination.
- Format and transparency. This is the check unique to a budget-driven tool. The output may be in a different format than the source — a PNG can become WebP or JPEG, a JPEG can become WebP, a WebP can become JPEG. The result panel labels the output format and lists any format change as a note. If the source had transparency and the output is JPEG, alpha was flattened onto white; the panel notes that. If you need transparency to survive, the output must be PNG or WebP, so raise the budget or uncheck "Keep original format" to allow WebP-with-alpha earlier. A dedicated walkthrough of PNG / WebP / JPEG transparency behaviour lives on the Transparent image formats guide.
- Real destination. Upload the final file to the actual page, CMS, email or design tool where it will be used, and view it there. Browser preview, design-tool preview and the live page can render colour, transparency and layout differently; the live destination is the only check that catches all of them at once. The Optimize Images for the Web guide recommends the same final check on the live page, and it is the last step before the file is shipped.
What the tool actually changes
A target-size compressor that only re-encoded in the source format would fail on tight budgets. This tool works through its levers in a fixed order. It searches encoder quality at the source dimensions (for PNG, the colour palette is the lever), then reduces the canvas and searches the source format again, and changes format only once the source format has failed at every size it is allowed to try. With "Keep original format" turned off, WebP and JPEG compete at full size from the start, which usually avoids a resize. The result panel reports which lever produced the output. The behaviour below is the real path the workflow runs, not marketing shorthand.
1. Same-format quality search
The encoder tries the source format at the original dimensions. JPEG and WebP are measured on Pillow's 0 to 100 quality scale: the lowest setting (10) is encoded first, so a budget the format cannot reach at this size is known after one encode, then the highest (92), then up to three interpolated guesses — the highest quality that still fits. PNG has no quality knob, so its palette is the lever. The encoder measures a 16-colour PNG first, because 16 colours is the smallest palette it will use: if that file is still over budget, this canvas cannot fit and the search moves to a smaller one. When it does fit, the encoder then tries lossless, 256 colours and 64 colours in that order, keeping as many colours as the budget allows and staying PNG.
2. Downscale inside the source format
When the quality floor, or the 16-colour PNG, is still over budget at full size, the next canvas size is estimated from the bytes the encoder just measured, and the same-format search runs again there. Each measurement refines the next estimate, rather than testing 90%, 80%, 70% one encode at a time. Reduction stops at a quarter of the source width and height, and never below 64 pixels on a side, using Pillow's LANCZOS filter. The tool never upscales. Any reduction is called out on the result panel as "Scaled to fit budget".
3. Format change, after the source format is exhausted
A conversion is tried only once the source format has failed at every size it was allowed to try. PNG goes to WebP lossy with alpha kept, then to JPEG on white; JPEG goes to WebP; WebP goes to JPEG. Those replacements are searched across canvas sizes too, so a converted file may also be smaller than the source. With "Keep original format" off, WebP and JPEG are searched alongside the source format at every size, which is the choice when the byte budget matters more than the file extension. Transparency is preserved when the destination format can carry it (PNG, WebP); JPEG always flattens alpha onto white. Every format change is listed on the result panel.
4. Best-effort fallback
If even the smallest scale cannot hit the budget, the panel returns the smallest file the encoders could produce and a "Could not reach X KB under the current constraints" note. The same applies when one request uses up its search budget — at most 15 encodes and about 20 seconds — which the note says plainly instead of carrying on. The result is honest: there is no padding to fake a hit and no silently-lowered quality without a note.
The strategy is anchored to
Pillow's encoder behaviour
and the LANCZOS downscale documented in Pillow's resize
reference; the strategy order is the one this tool actually
runs in compress_to_target.py,
not a marketing summary.
Reading the result panel
The result panel reports three measured values: the original file size, the output file size and the target. There is no promised reduction and no exact-KB guarantee — the panel shows the same numbers a file-size tool would measure on the source and output bytes. The result also reports the format, the quality and any format or scale notes as a list, so the user can see exactly which strategy the tool picked.
Three outcomes are possible, and all three are shown honestly:
- Met target. The output is at or under the KB target. The panel shows the measured bytes and the format / quality / scale notes that describe which strategy produced the output. This is the common case for moderate budgets on already-optimised sources.
- Best effort, target not met. The encoders cannot reach the budget at the current size and format. The panel shows the smallest file the encoders can produce and a "Could not reach X KB" note. The fix is to relax the budget, supply a smaller source image, or pick a different source — the tool is not hiding a smaller file behind a higher number.
- Source already under target. The source bytes are already smaller than the target, so the tool encodes nothing: it returns the original file byte for byte and reports met-target. Treat this as "no compression was needed".
The bytes shown on the panel are the source's own measurement, not an average for the format. Treat them as one data point: they tell you what happened on this specific file, not what will happen on the next file you compress.
Compress to KB vs Image Compressor
The two workflows answer different questions and they pair well rather than overlap. The Image Compressor uses one balanced default per format and never changes format or dimensions. The Compress to KB sweeps quality toward a user-set KB budget and may change format (PNG → WebP, PNG → JPEG) or scale dimensions when the budget cannot be met at the source settings. Use the Image Compressor when the destination already accepts the source format and there is no byte budget. Use this Compress to KB when a destination asks for "under X KB" or "max Y KB".
Both tools report measured sizes on the result panel, not promised reductions. Compress to KB is honest about the cases where the target cannot be hit — the panel shows the best-effort file and a "Could not reach X KB" note rather than padding the result. The right tool for a given file depends on whether the destination enforces a byte budget or just wants the smallest file in the same format; the two tools together cover both ends of that question.
What it does
Compress to KB is for destinations that ask for a size budget — “under 100 KB”, “max 200 KB” — rather than a single balanced quality default. It re-encodes with Pillow (same stack as Image Compressor), prefers the source format, and only changes format or dimensions when the budget requires it.
How to use it
- Upload a PNG, JPG or WebP up to 10 MB and within 20 megapixels; over that, the tool names the size to resize to first.
- Set the target size in KB (default 100) or tap a form/visa preset (50–250 KB). Exact KB is best-effort.
- Leave “Keep original format” on unless you are fine with JPEG/WebP sooner.
- Review the measured sizes, quality, and any format/scale notes, then download.
Frequently asked questions
Can I hit exactly 100 KB?
Does Compress to KB resize my image?
What happens to PNG transparency?
How is this different from Image Compressor?
Which formats are supported?
Is there a smallest target I can set?
Sources
- Pillow — Image.save (JPEG quality, optimize): https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#jpeg — JPEG quality and optimize parameters used in the quality sweep.
- Pillow — WebP saving options: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#webp — Lossy quality and lossless WebP encoding for opaque and alpha sources.
- Pillow — PNG optimize: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#png — Lossless PNG optimize pass before any format fallback.