Sub topic 3
Setting Compression Quality and Preparing Web Images
Assume you understand raster and vector images, common web formats, and basic HTML. This chapter focuses on making exports small without visible damage, then checking and handing them off.
Compare quality and file size
Compression quality is a trade-off between visual detail and file size. A higher JPEG or WebP quality usually preserves more detail but creates a larger file. Do not choose a setting by number alone. Export several versions, inspect them at their displayed size, and compare their byte sizes.
| Image content | Starting point | Check for |
|---|---|---|
| Photograph | JPEG or WebP quality 75–85 | Blockiness, halos, and lost texture |
| Flat illustration | PNG, WebP, or SVG | Jagged edges and color changes |
| Transparent image | PNG or WebP | Fringe pixels around transparent areas |
Use sRGB and remove unnecessary metadata
Export web images in sRGB, the color space browsers commonly expect. A different color profile can make colors appear dull or shifted. Strip camera, editing-history, and location metadata unless the project needs it. Metadata increases file size and can expose private information.
Serve the right file to each device
srcset lists alternate sizes. sizes tells the browser how wide the image will appear. Use picture when the format or crop needs to change.
<picture>
<source type="image/avif" srcset="hero-800.avif 800w, hero-1600.avif 1600w">
<source type="image/webp" srcset="hero-800.webp 800w, hero-1600.webp 1600w">
<img src="hero-800.jpg"
srcset="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">
</picture>Set a budget and verify
Agree on a budget, such as 200 KB for a large hero image and 100 KB for a card image. Use ImageMagick, an export panel, or a build tool to resize, compress, convert to sRGB, and strip metadata. In the browser, test desktop and mobile widths, a high-density screen, slow network conditions, sharp text, transparency, and the image's crop. Check the browser's network panel to confirm the expected file loads.
Name and hand off files
Use names that describe content and size:
team-desk-800.webpteam-desk-1600.webpbrand-mark.svg
Include the source file, export dimensions, format, quality setting, alt-text suggestion, and any crop rules. Keep 1x and 2x files clearly related.
Exercise
A 1600-pixel hero looks sharp but takes 900 KB. What should you try first?
Show answer
Export a smaller displayed-size variant, compare JPEG or WebP quality settings, remove metadata, and verify the result in the browser.