AI image tools often hand you a much larger file than the page needs: a 2400-pixel hero for a slot that shows at 800 pixels, saved as a PNG when a WebP would do. Images are often the heaviest resource on a web page, and sending extra pixels costs every visitor download time. The fix is not to guess a smaller size, but to work out the size the image is actually shown at and export to that.
Size it to the slot, times the screen
Google’s web.dev image guide says the first optimization is to display the image at the correct size, and that an image displayed in a 500 pixel by 500 pixel container would be optimally sized at 500 pixels by 500 pixels — while a square 1000 pixel image in that slot is twice as large as needed. Screens complicate it: a device with a device pixel ratio (DPR) of 2 needs a 1000 pixel image for that same 500 pixel container, and a DPR of 3 needs 1500 pixels. The rule is display size times DPR, no more.
Format matters as much as size. The same guide says modern image formats like WebP and AVIF may provide better compression than PNG or JPEG, making your image file size smaller and therefore taking less time to download. WebP often has better compression than JPEG, PNG, or GIF, and supports transparency even with lossy compression — a feature the JPEG codec does not offer. There is no universal compression setting: the guide recommends experimenting with different compression levels until you find a good compromise between image quality and file size.
The problem shows up in design files too. Figma’s forum reports that files with a lot of high-resolution images load blurry at first and then sharpen, because Figma only downloads high-quality versions of images in the current viewport — and its support team advises importing images at the size they will be used at rather than shrinking large imported images. That is the problem this check fixes: an oversized AI image slows the page and the file, and a too-small one cannot be fixed by stretching it.
Work out the numbers before you export
For each AI-generated image, write down where it will be shown, how wide it is displayed there, and the highest DPR you need to serve — usually 2. Multiply the display width by the DPR to get the export width. If the file is wider than that, resize it down. If the file is narrower, do not upscale it: use it smaller, or regenerate it larger. Then save it as WebP or AVIF, keep a JPEG or PNG fallback for older browsers, and compare the result by eye at a few quality levels.
Practice file-size check: fictional Maple Corner images
The five images below are fictional practice material. They were not exported or compressed for this guide; the table is a practice set so you can see how the check works, with the arithmetic worked out from the stated sizes.
| Image | Shown at | Needed (display x DPR) | File size | Result |
|---|---|---|---|---|
| Hero image | 800 x 400 | 1600 x 800 at DPR 2 | 2400 x 1200 | Too big — resize to 1600 x 800 |
| Square post | 540 x 540 | 1080 x 1080 at DPR 2 | 1080 x 1080 | Pass |
| Menu card | 600 x 400 | 1200 x 800 at DPR 2 | 600 x 400 | Too small — do not upscale, use it smaller |
| Thumbnail | 300 x 200 | 300 x 200 at DPR 1 | 300 x 200 | Pass |
| Leaf logo | 200 x 200 | Any size — vector | SVG | Pass — scales without losing quality |
Three of the five images are ready, and two need work in opposite directions: the hero is 800 pixels wider than it needs to be (2400 against 1600), and the menu card is 600 pixels narrower than its slot needs (600 against 1200). Resizing the hero down saves download time; upscaling the menu card would only make it blurry. The logo needs no resizing at all, because it is a vector.
What to do when the file is still too heavy
If the image is the right size and still heavy, change the format before you change the quality: try WebP, then AVIF, keeping a JPEG fallback. If it is a photo with sharp text or line art in it, expect lossy compression to struggle and test carefully. And do not forget the images nobody sees: a hero that loads below the fold and a thumbnail nobody clicks still cost download time.
Expected result. We checked the web.dev image performance guide. We did not run any image tool on the Maple Corner images.
Limits
This check covers size and format only. It does not check whether the image is the right image, whether it is accessible, or whether it may be used commercially. The DPR values above are practice values for the Maple Corner page, not a rule for every site — a page shown mostly on standard screens may need only DPR 1, and a retina-heavy audience may need DPR 3. Actual file sizes in kilobytes depend on the image content and the compression level, and no kilobyte figures are claimed here. Maple Corner is fictional, and the five images above are practice material.
Sources
- Image performance — web.dev — “An image displayed in a 500 pixel by 500 pixel container would be optimally sized at 500 pixels by 500 pixels. For example, using a square 1000 pixel image means that the image is twice as large as needed.” Also: “if the device has a DPR of 2 and the image is displayed in a 500 pixel by 500 pixel container, then a square 1000 pixel image (referred to as the intrinsic size) is now the optimal size.” And: “Modern image formats like WebP and AVIF may provide better compression than PNG or JPEG, making your image file size smaller and therefore taking less time to download.”
- Image loading issue — Figma Forum — “Figma only downloads high quality (larger than 512 by 512 pixels) versions of images in your current viewport. For images outside your current view, Figma loads a lower quality version to improve performance when you first load a file.” Figma’s support team advises making sure “images are imported into Figma at the size they will be used in your designs rather than shrinking large imported images.”
