Sub topic 7
Exporting assets at the right scales with clear names
This chapter assumes you have read the earlier chapters on file organization and asset formats. You should be able to name the job of SVG, PNG, JPEG, and WebP. You should also know what a frame, a slice, and a component are in your design tool. Export settings differ between Figma, Sketch, and Adobe XD, so this chapter describes the decisions rather than the menu items.
Why export is part of the handoff
A developer who receives a design file can inspect spacing and colors. Images are different. A developer cannot take a photo or a custom illustration out of a mockup without the designer's help. If the designer exports files carelessly, three problems follow:
- Blurry images. A 400 px file shown at 400 CSS pixels looks soft on a high-density screen.
- Heavy pages. A 4000 px photo sent to a phone wastes bandwidth and slows loading.
- Guesswork. Names like
Frame 238.pngorfinal_v3_new.pngforce the developer to ask what each file is and where it goes.
Exporting well means choosing a format, a set of sizes, and a name for every asset. The developer should be able to drop the files into the project and reference them without asking you anything.
Understanding scale
A CSS pixel is a layout unit. A high-density ("retina") screen packs several physical pixels into each CSS pixel. The ratio is the device pixel ratio (DPR). Most phones and laptops have a DPR of 2 or 3, and many desktop monitors have a DPR of 1.
To look sharp, a raster image (PNG, JPEG, WebP) needs about displayed width × DPR pixels. An icon displayed at 24 CSS pixels needs 24 px at 1x, 48 px at 2x, and 72 px at 3x.
Design tools usually work in CSS pixels. When you export "2x", the tool doubles the pixel dimensions of the same frame. Check that your design frame is at 1x before you trust the export suffix. A file designed at 2x and then exported at "2x" is four times too large in each direction.
Two ways to offer multiple sizes
HTML has two systems for offering several files of the same image:
| Approach | Attribute | Use it for | You export |
|---|---|---|---|
| Density descriptors | `srcset="a.png 1x, [email protected] 2x"` | Fixed-size images such as logos, avatars, and thumbnails | The same image at 1x, 2x, and optionally 3x |
| Width descriptors | `srcset="a-800.jpg 800w, a-1600.jpg 1600w"` plus `sizes` | Fluid images such as heroes and article photos | The same image at several pixel widths |
Use density descriptors when the displayed size never changes. Use width descriptors when the image grows or shrinks with the layout. For width descriptors, the sizes attribute tells the browser how wide the image will be displayed, so it can pick a file before the CSS has loaded.
Choosing what to export
Not every asset needs several sizes. Work through the decision for each asset:
- Icons, logos, and simple illustrations: Export a single SVG. It scales to any density, so it needs no
@2xvariant. - Photos: Export two to four widths. For a hero that fills half the viewport on desktop, 800 and 1600 pixels is a reasonable pair. Export WebP as the preferred file and JPEG as the fallback.
- Raster graphics with transparency: Export PNG or WebP. JPEG cannot store transparency.
- Screenshots and UI mockups inside the page: Export PNG or lossless WebP. Lossy compression smears text.
SVG export details
SVG files are code, so how you build the shape affects the output:
- Convert strokes to outlines only if the developer will not change the stroke width. Otherwise keep strokes.
- Convert text inside logos to outlines so the logo does not depend on an installed font.
- Remove hidden layers and unused masks before export. They are exported as extra markup.
- For icons that should change color on hover or in dark mode, use a single flat fill. The developer can then replace the fixed fill with
currentColorand control the color from CSS. - Keep the artboard tight and square for icons, such as 24 × 24, so every icon aligns the same way.
Naming exported files
A good name tells the developer what the file shows, where it is used, and which variant it is, without opening it. Agree on a convention and apply it to every export.
Use these rules:
- Lowercase only. Some servers treat
Hero.jpgandhero.jpgas different files. - Hyphens between words. Avoid spaces, underscores in URLs, and special characters.
- Start with a category, then the subject, then the variant, then the size.
- Describe content or role, not position or version.
hero-team-reviewages better thanimage-3orfinal. - Put the size last, as a width (
-800) or a density suffix (@2x), but not both in the same set.
| Asset | Poor name | Good name |
|---|---|---|
| Search icon | `Group 12.svg` | `icon-search.svg` |
| Filled variant | `icon-search-new.svg` | `icon-search-filled.svg` |
| Home page hero, 800 px WebP | `Frame 238.webp` | `img-hero-home-800.webp` |
| Same photo, 1600 px JPEG fallback | `hero final2.jpg` | `img-hero-home-1600.jpg` |
| Partner logo at 2x | `[email protected]` | `[email protected]` |
| Empty-state illustration | `illustration copy.svg` | `illus-empty-inbox.svg` |
The prefixes (icon-, img-, logo-, illus-) keep files grouped in a file browser and make a glob like icon-*.svg possible for build scripts.
If the layer or slice names in your design file already follow this convention, export names come out right automatically. This is why the file organization chapter matters: renaming one slice is cheaper than renaming forty files afterward.
Setting up the export
Set up exports in the design file, not on your machine. Most tools let you attach export settings to a layer, frame, or slice, and those settings stay with the file. The developer can then export an asset themselves if they need a new size.
For each asset, set:
- the layer or slice name (the file name),
- the format,
- the scale or width,
- any suffix that distinguishes variants.
Export from a slice or a frame that has exactly the size you want. If the exported file has a lot of empty margin, the developer has to crop it or compensate with CSS offsets. Check that the exported bounds match the visible shape.
Organize the delivered folder so it mirrors how the developer will use the files:
assets/
icons/
icon-search.svg
icon-close.svg
images/
img-hero-home-800.webp
img-hero-home-1600.webp
img-hero-home-800.jpg
img-hero-home-1600.jpg
logos/
logo-partner-acme.png
[email protected]
illustrations/
illus-empty-inbox.svg
assets.jsonAdding a manifest
File names cannot carry everything. Alt text, display size, and usage notes belong in a small manifest next to the files. A short JSON file works well and can be read by people and scripts:
{
"img-hero-home": {
"files": [
"img-hero-home-800.webp",
"img-hero-home-1600.webp",
"img-hero-home-800.jpg",
"img-hero-home-1600.jpg"
],
"aspectRatio": "16:9",
"displayWidth": "50vw at 960px and above, 100vw below",
"alt": "Team reviewing a design on a shared screen",
"loading": "eager"
},
"icon-search": {
"files": ["icon-search.svg"],
"displaySize": "24px",
"alt": "",
"note": "Decorative. The button next to it carries the label."
}
}An empty alt is a deliberate choice for decorative images. Recording it tells the developer that the empty value is intended and not forgotten.
From export to markup
The developer should be able to turn the exported set into markup directly. The picture element below uses the hero files from the example folder:
<picture>
<source type="image/webp" srcset="img-hero-home-800.webp 800w, img-hero-home-1600.webp 1600w" sizes="(min-width: 960px) 50vw, 100vw">
<img src="img-hero-home-800.jpg" srcset="img-hero-home-800.jpg 800w, img-hero-home-1600.jpg 1600w" sizes="(min-width: 960px) 50vw, 100vw" width="800" height="450" alt="Team reviewing a design on a shared screen">
</picture>Each part traces back to a handoff decision:
- The
sourceelement offers WebP first. Browsers that support WebP use it, and others fall through to theimg. - The
wdescriptors state the real pixel width of each file. These numbers must match the exported files, so exact sizes matter. sizescomes from your responsive spec: half the viewport on wide screens, full width otherwise.widthandheightgive the browser the aspect ratio before the image loads. The page reserves the space and avoids layout shift.altcomes from your manifest.
For a fixed-size image such as a logo, the markup is simpler:
<img src="logo-partner-acme.png" srcset="logo-partner-acme.png 1x, [email protected] 2x" width="120" height="40" alt="Acme">Images set as CSS backgrounds can also be offered at several densities with image-set():
.promo {
background-image: url("img-promo-bg.jpg");
background-image: image-set(
url("img-promo-bg.jpg") 1x,
url("[email protected]") 2x
);
background-size: cover;
}The first declaration is the fallback for browsers that do not understand image-set().
Common errors and edge cases
- Exporting at the wrong base. If the frame was drawn at 2x, a "1x" export is already double size. Confirm the frame width matches a real CSS width, such as 1440 or 375.
- Upscaling. Never export a 1600 px file from a 900 px source. It gets larger but not sharper. Ask for a better source image.
- A fallback that is much heavier. If the JPEG is five times the size of the WebP, check the quality setting. Compare file sizes before delivering.
- Cropping that varies by breakpoint. If the photo is cropped differently on mobile, one file will not work. Export separate crops and mark them in the manifest, so the developer can use
sourceelements with amediacondition. - Text baked into images. Text in a PNG cannot be translated, resized, or read by a screen reader. Keep real text in the layout and export only the picture.
- Gradients and shadows in raster exports. A CSS gradient or
box-shadowis smaller and sharper than an exported image. Describe these in the specs instead of exporting them. - Unoptimized files. Run exports through a compression step, or set quality in the tool. Remove metadata such as camera data from photos.
Checklist before you deliver
- Every asset has a format chosen from the decision path.
- Icons and logos are SVG, with outlined text and no hidden layers.
- Photos have at least two widths, in WebP with a fallback.
- File names are lowercase, hyphenated, prefixed, and end with their size.
- Export settings are saved in the design file.
- The manifest lists the displayed size, aspect ratio, and alt text of each asset.
- Files sit in a folder structure that matches the project.
Exercise
A card image is always displayed at 300 CSS pixels wide, on every screen size. Which srcset descriptor style fits, and which pixel widths should you export to support screens with a DPR of 1, 2, and 3?
Show answer
Use density descriptors (1x, 2x, 3x), because the displayed size is fixed. Export the image at 300, 600, and 900 pixels wide (300 × 1, 300 × 2, and 300 × 3). Name them for example img-card-promo.jpg, [email protected], and [email protected]. Many teams skip 3x for photos, since 2x is usually enough and 3x adds weight.
Exercise
A designer delivers Hero Final 2.JPG (4200 px wide) and Group 7.svg for a search icon. List what is wrong and give better names and exports.
Show answer
The hero file has spaces, mixed case, a meaningless version label, and an uppercase extension. It is also far wider than any layout needs and is only one size. Export WebP and JPEG at 800 and 1600 pixels, named img-hero-home-800.webp, img-hero-home-1600.webp, img-hero-home-800.jpg, and img-hero-home-1600.jpg. Group 7.svg is a default layer name that says nothing about the content. Rename it icon-search.svg, and check that it has a tight artboard, no hidden layers, and a single flat fill so CSS can recolor it.
Exercise
Your sizes attribute says (min-width: 960px) 50vw, 100vw. On a 1440 px wide viewport with a DPR of 2, about how many pixels wide should the chosen image be, and which file from the 800w/1600w set does the browser pick?
Show answer
At 1440 px, 50vw is 720 CSS pixels. At DPR 2 the browser wants about 1440 physical pixels. The 1600w file is the closest one that is at least that wide, so the browser picks it. The 800w file would be upscaled and look soft.