Sub topic 18
Verifying Exported Images
This chapter assumes you can export images in the formats covered earlier (JPEG, PNG, SVG, WebP, AVIF). It also assumes you know your export dimensions, 1x and 2x scales, and quality settings. Here you check that the files you made are the files the browser actually loads, and that they meet your size budget.
A file can look fine in your design tool and still fail on a real page. The wrong scale may load. The format may fall back to an older one. The image may be much larger than its slot. Checking in the browser catches these problems before developers do.
What to verify
Check each exported image against five questions:
- Is the file the format you intended?
- Is its pixel size right for the slot it fills, at 1x and 2x?
- Is its file size within budget?
- Does it look good at the size and density where it is shown?
- Does the browser load the file you expect, not a different one?
The first three can be checked on your computer. The last two need a browser.
Check files before the browser
Start with the files on disk. Reading them takes seconds and finds most export mistakes.
In a file manager, look at the file type, pixel dimensions, and size in KB. On the command line, ImageMagick's identify prints the same details for many files at once.
identify -format "%f %m %wx%h %b\n" hero-800.jpg hero-1600.jpg hero-1600.webpThe output shows the file name, format, pixel width and height, and file size. For example, hero-1600.webp WEBP 1600x900 96KB. Compare each line with what you planned.
Common findings at this stage:
- A
.jpgfile that is really a PNG, because the extension was renamed by hand instead of exporting. - A 2x file with the wrong size. A slot of 400 by 225 CSS pixels needs a 2x file of 800 by 450 pixels.
- A file much larger than the others in its set, often because metadata was not stripped or quality was left at its maximum.
The %m field reports the real format, so it catches the renamed-file mistake.
Check the page in the browser
Open the page in a desktop browser and use the developer tools. The steps below use Chrome-style names. Firefox and Safari have close equivalents.
Network panel
- Open developer tools and choose the Network panel.
- Filter by Img.
- Reload the page with the cache disabled. There is usually a "Disable cache" checkbox in the panel.
- Look at each row.
Each row shows the file name, type, transferred size, and load time. Use these columns to answer the earlier questions:
| Column | What to check |
|---|---|
| Name | Is it the file you expected, such as `hero-800.jpg` and not `hero-1600.jpg`? |
| Type | Is it `avif`, `webp`, `jpeg`, `png`, or `svg+xml` as planned? |
| Size | Is the transferred size within your budget? |
| Time | Does a large image delay the page? |
The Type column is how you confirm that a picture element is working. If you listed AVIF first and the browser supports it, you should see avif, not jpeg. If you see jpeg, check that the type attribute and the file path are correct.
Intrinsic size and rendered size
Hover over an image link in the Elements panel, or inspect the image. The browser shows two sizes:
- The rendered size, which is the space the image takes on the page in CSS pixels.
- The intrinsic size, which is the pixel size of the file.
At 1x density, the intrinsic size should be close to the rendered size. At 2x, the intrinsic size should be about double. A 1600-pixel file in a 400-pixel slot on a 1x screen wastes bandwidth.
Intrinsic size below rendered size is worse. The browser stretches the image and it looks soft.
Testing different densities and widths
Responsive images choose a file based on screen width and density. To test this:
- Turn on device mode and pick a phone preset, which usually uses 2x or 3x density.
- Reload the page. Selection happens at load time, and in some browsers it does not re-run on resize.
- Check the Network panel again and note which file loaded.
- Repeat with a wide desktop window.
Write down the result for each case:
| Viewport | Density | Expected file | Loaded file |
|---|---|---|---|
| 390 px wide | 3x | `hero-1600.jpg` | (fill in) |
| 1280 px wide | 1x | `hero-800.jpg` | (fill in) |
| 1280 px wide | 2x | `hero-1600.jpg` | (fill in) |
If the loaded file differs from the expected one, the usual cause is the sizes attribute. It tells the browser how wide the image will be before layout is known. A wrong sizes value makes the browser choose a file that is too large or too small.
<img
src="hero-800.jpg"
srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1600.jpg 1600w"
sizes="(min-width: 960px) 800px, 100vw"
width="800"
height="450"
alt="Team working at a shared desk">For this markup, a 390-pixel phone at 3x needs about 1170 pixels. The browser picks hero-1600.jpg. A 1280-pixel desktop at 1x shows an 800-pixel slot and picks hero-800.jpg. At 2x, the same slot needs 1600 pixels.
Check how it looks
Numbers do not show artifacts. Look at the image on the page at the size and density where people will see it.
- Zoom the browser to 100% and look at edges, text in images, and gradients.
- Check for blocky areas and color banding in skies and soft backgrounds. These are typical of quality set too low.
- Look for halos around sharp edges and text. These are also compression artifacts.
- Check transparent PNG, WebP, and AVIF files on both light and dark backgrounds. Edges that were exported against a white background can show a light fringe on dark pages.
- Check SVGs at several sizes. An SVG that uses
currentColorshould take the text color of its surroundings.
If you did the visual comparison in the compression chapter, this step confirms that the result holds up inside the real page.
Check the size budget
Compare each image with the budget you set for its role. A simple record keeps this honest.
| Image | Role | Budget | Actual | Pass |
|---|---|---|---|---|
| `hero-1600.avif` | Hero | 150 KB | 78 KB | Yes |
| `hero-1600.webp` | Hero fallback | 150 KB | 96 KB | Yes |
| `hero-1600.jpg` | Last fallback | 200 KB | 241 KB | No |
Use the transferred size in the Network panel, not only the size on disk. They can differ when a server compresses responses. Images are already compressed, so for them the two numbers are normally close. SVG is text, so a server may compress it, and transferred size can be much smaller than file size.
Also add up the images that load on first view. Several images within budget can still exceed the page total. Only count images that load without scrolling, since lazy-loaded images below the fold do not delay the first view.
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| JPEG loads where AVIF was expected | Wrong `type` value or file path in `source` | Check `image/avif` and the file name |
| Phone loads the largest file | `sizes` missing or set larger than the slot | Set `sizes` to the real display width |
| Image looks soft on a high-density screen | Only a 1x file exists | Export a 2x file and add it to `srcset` |
| Page shifts as images load | Missing `width` and `height` | Add both attributes in CSS pixels |
| Colors look dull or shifted | File not in sRGB | Convert to sRGB and re-export |
| File larger than expected | Metadata left in, or quality too high | Strip metadata and lower quality |
| Light fringe on dark background | Transparency edges blended with white | Re-export with a matching matte or from a transparent source |
The layout shift row matters even though it is not about file size. The width and height attributes let the browser reserve space before the file arrives. You can see it in the browser: reload on a throttled connection and watch whether the text moves when images appear.
Throttle the connection
Your own connection hides problems. In the Network panel, set throttling to a slow preset such as "Fast 3G" and reload. Watch which images appear first, how long the main image takes, and whether the layout moves. An image that is "fast enough" on office Wi-Fi may take several seconds here. This test shows whether your budget is realistic.
A short sign-off routine
- Run
identifyon the files and compare format, size, and weight with the plan. - Load the page with cache disabled and note each image's Type and Size.
- Compare rendered size and intrinsic size at 1x and 2x.
- Test a phone width and a desktop width and record the loaded files.
- Inspect the images at 100% zoom, including transparency on dark and light backgrounds.
- Reload on a throttled connection and watch for layout shift.
- Record results against the budget table and fix any failures.
Exercise
A page uses a picture element with an AVIF source, a WebP source, and a JPEG img. In the Network panel on a current desktop browser, the hero loads as jpeg. List two things you would check, and say how the Type column helps you.
Show answer
Check that each source has the correct type value (image/avif, image/webp) and that the srcset paths point to files that exist. A wrong type or a broken path makes the browser skip that source and fall back to the JPEG. The Type column shows which format actually loaded, so it tells you the fallback happened. Running identify on the AVIF and WebP files also confirms they are real files in those formats.
Exercise
A card image has a rendered size of 300 by 200 CSS pixels. On a 2x phone, the Network panel shows a file with an intrinsic size of 300 by 200. What is wrong, what size should the file be, and what would you change?
Show answer
The file is a 1x file on a 2x screen, so the image looks soft. The 2x file should be 600 by 400 pixels. Export it and add it to srcset with a 2x descriptor, such as card.jpg 1x, [email protected] 2x, or add a 600w entry with a correct sizes value.
Exercise
Your hero JPEG has a budget of 200 KB, and the Network panel shows 241 KB. Name two export changes that could fix it, and one check to make after the change.
Show answer
Lower the quality setting (for example from 90 to 80) and strip metadata. Resizing the file to the largest size the page needs also helps. After the change, view the image at 100% zoom to confirm that no blocky areas or banding appeared, and recheck the transferred size against the budget.