Compare image formats using a consistent crop, real export quality and fallbacks.
Choose an image format after considering what the page needs to show. A photograph can tolerate small changes to texture that would make a line diagram or a compressed screenshot harder to read. A transparent logo needs alpha transparency if it must sit on multiple backgrounds. A high-resolution hero also needs an export suited to the space it occupies. Compare the file sizes after choosing the pixel dimensions, then judge the smallest plausible versions on the page where visitors will see them.
Match the first export to the source
JPEG is a practical starting point for photographs, especially when the same file needs to open in older software. It stores a lossy representation and does not support an alpha channel. A screenshot with small text and flat backgrounds can show coloured fringes around letters if compressed the same way as a photo. PNG preserves the original pixel values and can preserve transparency. It may be small for a diagram with repeated colours and considerably heavier for a detailed photograph.
WebP can be encoded in lossy or lossless form and can carry transparency. Try it for a web photograph or a transparent asset after deciding whether exact pixel values matter. AVIF also supports transparency and offers strong lossy compression for many photographs. The best result depends on the encoder, the quality setting and the source. Two quality sliders marked with the same number in different tools or formats have no guaranteed visual equivalence. Compare the outputs at the size people will see.
Compare the same crop and dimensions
Begin with the original or another high-quality source. Export the exact same composition and width in each format. Keep track of what each export contains because a tool might remove metadata, convert a profile or flatten transparency. If possible, save your artwork as a master separate from any delivery files. Repeatedly decoding and re-encoding a lossy image can worsen artefacts even when the last export uses a high quality setting.
Open the images at their intended display width and check detailed features. In a portrait, inspect hair and fine skin texture. In a landscape look for banding in a sky gradient and smudging in foliage. In screenshots pay attention to punctuation, straight border lines and low-contrast text. View a translucent edge against the backgrounds where it will appear. A dark matte from an earlier export can leave a visible rim even if the final file type supports transparency.
Use the WebP batch converter for alternate widths and Palleon Image Editor for visual edits such as cropping. Keep dimensions and quality settings in a record alongside sample filenames. If the result looks wrong, having a record lets you reproduce the issue with a higher setting or export an alternative from the master.
Deliver a preferred source and a fallback
A picture element lists optional sources in preference order, with an image element at the end. The browser can pick a supported type. An image element supplies the alternative text, fallback source and intrinsic dimensions. Make the fallback the same subject and aspect ratio unless you are intentionally supplying a different composition at certain widths. Otherwise, the chosen type can change what the alternative text describes or cause the layout to move when the image loads.
The type attribute tells the browser what kind of file to expect. Point every source to a real export and ensure its content type is correct on the server. An unavailable image URL is a deployment error, so confirm the preferred source and the fallback independently. Check the network panel or the resolved image source to see what was selected. If testing an AVIF export in a separate system such as a CMS, image library or email workflow, check that system too because it may decode, transform or reject files before they reach the browser.
Try a self-contained picture example
This preview offers a vector drawing plus a small PNG fallback so it works without fetching external files. Use the button to switch the preferred source on and off. The page shows the selected type, and the display size stays fixed. Substitute the URLs of your real AVIF, WebP and JPEG or PNG exports following the same source order. In a production page, use file URLs so image resources can be cached independently.
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Picture source selection</title>
<style>
body { max-width: 32rem; margin: 1.5rem auto; padding: 0 1rem; font: 1rem/1.5 system-ui; }
img { display: block; width: 10rem; height: auto; margin-top: 1rem; background: #bce9ff; image-rendering: pixelated; }
</style>
<h1>Check picture source selection</h1>
<button id="switch" type="button">Use fallback</button>
<picture>
<source type="image/svg+xml" srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3Crect%20width='1'%20height='1'%20fill='%2327a672'/%3E%3C/svg%3E">
<img width="1" height="1" alt="A colour sample" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jR2QAAAAASUVORK5CYII=">
</picture>
<p role="status">Waiting for the image.</p>
<script>
const image = document.querySelector('img');
const source = document.querySelector('source');
const status = document.querySelector('[role=status]');
const button = document.querySelector('#switch');
function report() {
const type = image.currentSrc.startsWith('data:image/svg+xml') ? 'SVG' : 'PNG';
status.textContent = 'Selected source: ' + type;
}
image.addEventListener('load', report);
if (image.complete && image.naturalWidth) report();
image.addEventListener('error', () => { status.textContent = 'Image could not be decoded.'; });
button.addEventListener('click', () => {
const preferDrawing = source.media === 'not all';
source.media = preferDrawing ? '' : 'not all';
button.textContent = preferDrawing ? 'Use fallback' : 'Use preferred source';
});
</script>
</html>
Try it in the HTML editor
Check transparency, colour and metadata
A transparent image has pixel colours and opacity values. When exporting a logo, inspect the edge rather than checking only the fully transparent corners. When a tool offers a single background colour for a JPEG, decide which colour will be used and verify it after export. A transparent file is more flexible if the site also offers dark mode. An opaque field may be appropriate for a chart if its legend was designed specifically for that surface.
Some files contain metadata for orientation, colour or the device that created them. Check that the exported image still faces the right way and looks as expected across viewing software. Remove embedded location details from public images when they are unnecessary, while preserving any colour information your workflow relies on. Photography, product samples and diagrams may have different tolerances. Compare the deployed page against an approved source when consistent colour matters.
Validate the delivered assets
Open each published image URL individually and check both its response and appearance. Test a narrow viewport, a denser screen if possible and a repeat visit. If the page delivers several widths, verify that it selects a sensible candidate for the layout. Use the recorded network size to compare what actually transferred. A small file selected for a thumbnail is irrelevant if the page is requesting a larger version for that location.
Keep source artwork organised separately from generated exports so you can rebuild after cropping or design changes. Store aspect ratios and expected uses next to the export settings. When applying a new batch default, select one photo, one image with text and one transparent image for review before converting the rest. The MDN image format guide describes encoding and support details for the formats discussed here.
Make a note of the trade-off you selected
Suppose you are choosing a hero photograph and a small badge from the same photo shoot. The hero may benefit from several widths and a modern preferred format. The badge may include overlaid text where lossless detail helps. Write down separate decisions for the two locations. This is more useful to a future editor than a rule that all files must use the same encoder. If a different format is required by a downstream system, preserve it as an output of the master asset rather than converting a previously compressed web export.
Evaluate the smallest usable file
For a fair comparison, review the outputs without seeing their filenames if another person can prepare them. Start at normal display size, then zoom in far enough to identify where differences come from. Ask whether a visible difference affects the purpose of the picture. A lower quality asset could be acceptable as a thumbnail while a detailed texture or map needs a larger budget. Compare an alternative width as well as another compression setting. A well-chosen width often removes more bytes than another step down on a quality slider.
Check the size of exported files on disk before upload and verify again after delivery. A publishing platform may produce a different format or a resized derivative. If the delivered file differs, use the derivative in your final comparison. Record what the site serves so a later update can test the same resource.