Sub topic 17
Export tools and workflow
This chapter assumes you know the formats (JPEG, PNG, SVG, WebP, AVIF), how to pick export dimensions and 1x/2x scales, how to set compression quality, and what color space and metadata mean. Here you will put those choices into a repeatable workflow. The workflow uses your design tool's export panel for most work and a command-line tool when you need batches or tighter control.
Why a workflow matters
A single export is easy to get right. The trouble starts when you have forty images, two scales, three formats, and a redesign next month. A workflow turns your decisions into steps you can repeat. It also gives you one place to change a setting, such as quality, instead of re-exporting by hand.
Most export mistakes come from the same few causes:
- Exporting from a layer that was scaled up, which gives soft images.
- Forgetting the 2x file, so the image looks blurry on high-density screens.
- Leaving metadata and a wide color profile in the file.
- Using different quality settings on similar images, so the page looks uneven.
Step 1: Prepare the source
Export from the largest, cleanest source you have. Keep the original photo or the master design file untouched, and treat exports as disposable output that you can regenerate.
- Find the largest size the image will be displayed at. For a 800 px wide hero that must stay sharp at 2x, you need a source at least 1600 px wide.
- Check that the source is not smaller than that. Upscaling a small source adds pixels but no detail.
- Set the file's color profile to sRGB before export, or confirm that the tool converts to it.
- Name the frame or layer you will export. Names carry through to filenames, so a clear name now saves renaming later.
Step 2: Export from the design tool
Figma, Sketch, Photoshop, and Illustrator all have an export panel. The names differ, but the controls map to the same decisions.
| Decision | Figma | Sketch | Photoshop | Illustrator |
|---|---|---|---|---|
| Scale (1x, 2x) | Export scale | Size menu | Export As, scale | Export for Screens, scale |
| Format | Format menu | Format menu | Format menu | Format menu |
| Quality | JPEG/WebP quality slider | JPEG quality slider | Quality slider | Format options |
| Filename suffix | Suffix field (for example `@2x`) | Suffix field | Suffix field | Suffix field |
Use the suffix field to produce a matched set in one pass. Adding a 1x and a 2x export to the same layer gives you hero.jpg and [email protected] together. That matches the naming used in the srcset examples earlier in this tutorial.
Keep these habits:
- Export vectors as SVG, and rasters as JPEG, PNG, or WebP, according to your format choice.
- Turn off any option that embeds a color profile other than sRGB, or any option that includes extra metadata.
- Do not rely on a tool's default quality. Defaults change between versions and between tools.
Step 3: Batch and refine on the command line
Design tools are good for a handful of images. For a whole folder, or to produce several formats from one source, use command-line tools. Two common ones are ImageMagick for resizing and JPEG or PNG output, and cwebp for WebP.
magick hero.png -resize 1600x -strip -quality 80 hero-1600.jpg
cwebp -q 80 hero-1600.png -o hero-1600.webpThe first command resizes to 1600 pixels wide, removes metadata with -strip, and writes a JPEG at quality 80. The second writes a lossy WebP at quality 80 from a PNG of the same size.
To process many files, wrap the command in a loop. This script makes 400, 800, and 1600 px wide JPEGs for every PNG in the current folder. It needs ImageMagick 7 installed.
#!/usr/bin/env bash
set -euo pipefail
for src in *.png; do
name="${src%.png}"
for width in 400 800 1600; do
magick "$src" -resize "${width}x" -strip -quality 80 "${name}-${width}.jpg"
done
doneThe quotes around $src and the output name keep the script working when a filename contains a space. The set -euo pipefail line stops the script at the first error instead of silently producing partial output.
Choosing between the two approaches
| Situation | Better choice |
|---|---|
| A few images, visual comparison needed | Design tool export panel |
| Many images or many sizes | Command line script |
| AVIF or WebP not offered by your design tool | Command line or an export plugin |
| Same settings must be applied every time | Script, kept in version control |
| Image needs hand-tuned retouching | Design tool |
Step 4: Produce the full set
A typical responsive image needs several files. The diagram shows how one source fans out.
Nine files from one image is normal for a hero. Reserve this full set for images that are large or important. For small images, one or two sizes and one or two formats is enough. Producing more files than the page uses wastes your time and adds clutter for developers.
Step 5: Use the files in the page
The exported set maps directly onto the markup. The browser picks the first source whose format it supports and falls back to the JPEG.
<picture>
<source type="image/avif" srcset="hero.avif">
<source type="image/webp" srcset="hero.webp">
<img src="hero.jpg" width="800" height="450" alt="Team working at a shared desk">
</picture>For several widths of one format, use srcset with w descriptors and sizes:
<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">The width and height attributes reserve space so the page does not jump while the image loads.
Common errors
- Exporting the same image at 2x from a 1x source. The file is bigger and no sharper. Re-export from the original.
- Different quality values across a set. Pick one starting value per format, such as 80, then adjust only after comparing results.
- Overwriting masters. Write exports to a separate folder such as
export/so a script never replaces a source. - Forgetting
-strip. Camera metadata can add kilobytes and may include location data. - Trusting the tool's preview alone. The next chapter covers checking exports in the browser.
Summary of the workflow
- Start from the largest clean source in sRGB.
- Export a few images from the design tool, using suffixes for 1x and 2x.
- Script batches and extra formats on the command line.
- Produce only the sizes and formats the page uses.
- Map the files to
img,srcset, orpicturemarkup. - Verify in the browser, then hand off.
Exercise
You have a 1200 px wide photo, and the design needs it displayed at 800 px wide with a 2x version for high-density screens. A teammate exports the 2x file by scaling the 1200 px file up to 1600 px. What is wrong with this, and what should you do instead? Also name the command-line option that removes metadata in ImageMagick.
Show answer
Scaling a 1200 px file up to 1600 px adds pixels but no detail, so the 2x file is larger and still soft. Go back to the original, larger source (at least 1600 px wide) and export the 2x file from it. If no larger source exists, export only the 1200 px version and accept that the 2x display will be less sharp. The ImageMagick option that removes metadata is -strip.
Exercise
Write the ImageMagick command that resizes input.png to 800 pixels wide, strips metadata, and saves it as a JPEG at quality 75 named input-800.jpg.
Show answer
magick input.png -resize 800x -strip -quality 75 input-800.jpg