Sub topic 6
Choosing asset formats: SVG, PNG, JPEG, and WebP
This chapter assumes you can export from a design tool and know what a vector shape and a raster image are. You also need to read a basic HTML img tag. By the end, you should be able to pick a format for each asset in a handoff and say why.
Why format choice belongs in the handoff
A developer cannot tell from a screenshot whether a logo should be a vector or a bitmap. If the handoff doesn't say, they guess. A wrong guess costs real things: blurry icons on high-density screens, photos that weigh 2 MB, or a flat illustration with muddy edges.
Two questions decide most cases:
- Is the image made of shapes (vector) or pixels (raster)?
- Does it need transparency, or is it a photograph?
The four formats
- SVG is a vector format written as text. It describes shapes and paths, so it scales to any size without blur. Use it for icons, logos, and simple illustrations.
- PNG is a lossless raster format. It keeps every pixel exactly and supports transparency. Use it for screenshots, sharp-edged graphics that can't be vector, and images that need an alpha channel.
- JPEG is a lossy raster format. It discards detail the eye barely notices to get small files. It has no transparency. Use it for photographs.
- WebP is a modern raster format that supports both lossy and lossless compression, and transparency. Files are usually smaller than equivalent JPEG or PNG. All current major browsers support it.
| Asset | Best format | Reason |
|---|---|---|
| Icon, logo | SVG | Sharp at any size, small file |
| Photo | WebP, with JPEG fallback | Smaller files, wide compatibility |
| Screenshot with text | PNG or lossless WebP | No compression artifacts around text |
| Photo with transparent background | WebP or PNG | JPEG cannot store transparency |
| Flat illustration | SVG if simple, otherwise WebP or PNG | Vector stays small only while the shapes are few |
Worked example: a hero photo
Suppose the design has a hero photo that fills half the screen on desktop and the full width on mobile. In the handoff you list the photo as a WebP export at two widths, plus a JPEG fallback. The developer can then write this:
<picture>
<source type="image/webp" srcset="hero-800.webp 800w, hero-1600.webp 1600w" sizes="(min-width: 960px) 50vw, 100vw">
<img src="hero-800.jpg" srcset="hero-800.jpg 800w, hero-1600.jpg 1600w" sizes="(min-width: 960px) 50vw, 100vw" width="800" height="450" alt="Team reviewing a design on a shared screen">
</picture>Here is what each part does:
- The
sourceelement offers WebP. A browser that supports it uses that file and ignores theimgsources. - The
imgelement is the fallback, and it also carries thealttext and dimensions. srcsetlists the files with their widths, andsizestells the browser how wide the image will display. The browser then picks a file that fits.widthandheightlet the browser reserve space before the image loads. This prevents layout shift, where content jumps as images arrive.
Common errors
- Exporting a photo as PNG. The file is often several times larger than the same photo as JPEG or WebP, with no visible gain.
- Exporting text-heavy graphics as JPEG. Lossy compression leaves fuzzy halos around letters.
- Using SVG for a detailed photo-like illustration. Thousands of paths produce a file larger than a raster version.
- Leaving SVG text as live text. If the font isn't loaded, the text renders in a fallback face. Convert it to outlines, or tell the developer which font to load.
- Skipping the fallback. Without a JPEG or PNG fallback, a few older browsers show nothing.
Exercise
A design includes a company logo, a product photo on a plain background, and a screenshot of a dashboard with small text. Which format would you specify for each, and why?
Show answer
Logo: SVG, because it is made of shapes and must stay sharp at every size. Product photo: WebP with a JPEG fallback, because it is a photograph and lossy compression gives small files. Dashboard screenshot: PNG or lossless WebP, because lossy compression would blur the small text.
Exercise
A developer reports that a transparent-background product cutout looks fine in the design file but has a white box around it on the page. Which format was likely exported, and what should change?
Show answer
It was likely exported as JPEG, which has no transparency. Re-export it as WebP or PNG so the alpha channel is kept.