Why is my AI-generated image so big?
Ask an image generator for a picture and you'll usually get a PNG back. It looks right. Then you check the file and it's two megabytes, sometimes five. Dropped straight onto a page, it's the slowest thing on it.
The format is the reason. PNG is lossless: it stores every pixel exactly as rendered, and the encoder never discards detail on the grounds that nobody would notice. That's the right behaviour for something you'll archive or edit again later. It's the wrong behaviour for a file a browser has to download before anyone sees the page.
How much bigger is it, really?
Here's one photographic image at 1024 × 1024 — the size most generators default to — saved four ways:
| Saved as | Size | vs PNG |
|---|---|---|
| PNG, as generated | 1.9 MB | baseline |
| PNG, through a lossless optimiser | 1.9 MB | 2% smaller |
| WebP, quality 85 | 264 KB | 86% smaller |
| WebP, quality 80 | 212 KB | 89% smaller |
The second row is the interesting one. Running a photographic PNG through a lossless optimiser — stripping metadata chunks, recompressing with better settings — saved under two per cent. There's nothing left to win without changing format. The saving comes from switching to WebP, not from squeezing PNG harder.
At quality 85 the file is roughly a seventh of the size. Side by side at normal viewing distance there's nothing to see, which is the whole point of a lossy encoder: it spends its effort on the detail you'd notice and gives up the rest.
Resize before you convert
Generators output big squares. A 2048 × 2048 image sitting in a 720-pixel-wide column is carrying about eight times the pixels anyone can see, because it's the area that counts, not the width. Resize to the size it will actually display at first, then convert — the encoder has far fewer pixels to work through and the result is smaller again.
WebP or AVIF?
WebP is the safe default: every current browser reads it, encoding is quick, and it keeps transparency if the generator gave you any. AVIF compresses harder still, at the cost of noticeably slower encoding. If you're weighing the two up, WebP vs AVIF vs JPG goes through the trade in detail.
One exception worth knowing. If the image is mostly flat colour, hard edges or text — a logo, a diagram, a UI mockup — PNG is doing a job lossy formats do badly, and you should keep it. The table above is a photograph; a flat-colour image behaves nothing like it.
Check what the generator left in the file
Some generators write the model name, the prompt and a timestamp into the file's metadata. If you'd rather not publish the prompt alongside the picture, strip the metadata before the file goes anywhere.
Convert from the PNG the generator gave you, not from a copy you've already converted once. Every lossy encode works from whatever it's handed, so going PNG to WebP to WebP throws detail away twice.
The short version
- 1Resize to the size the image will actually be displayed at.
- 2Convert to WebP — quality 80 to 85 is the usual sweet spot for photographic images.
- 3Keep PNG only for flat colour, text or hard edges.
- 4Strip the metadata if the generator embedded your prompt.
Resize, convert to WebP and compress a whole folder in one pass, in your browser.
Optimize images for web