Sub topic 12
Export layers and artboards as separate assets
This chapter assumes you can already use the Export As dialog, you know the difference between JPEG and PNG, and you understand how 1x and 2x scales relate to pixel dimensions. Here you will learn how to turn one Photoshop document into many files without exporting each piece by hand.
Why export pieces instead of the whole document
A web or app design often lives in a single PSD. It holds an icon set, a hero banner, a badge, and several variants of a logo. Flattening and exporting the whole document gives you one file. You usually need many small ones, each with its own name, format, and scale.
Photoshop gives you three ways to do this:
| Method | Where | Best for |
|---|---|---|
| Export layers or artboards through Quick Export or Export As | Right-click in the Layers panel | One-off exports of selected items |
| Generate Image Assets | File > Generate > Image Assets | Assets that re-export automatically as you edit |
| Artboards | Artboard tool, then export | Screens, sizes, or variants of a design |
All three rely on the same idea. A layer, a layer group, or an artboard is treated as its own image, cropped to the bounds of its visible pixels.
Export a single layer or group
To export one layer or group without touching the rest of the document, follow these steps.
- Select the layer or group in the Layers panel.
- Right-click it and choose Quick Export as PNG or Export As.
- In Export As, choose the format, scale, and canvas options, then click Export.
Photoshop crops the output to the layer's visible content. A 40 x 40 icon on a 2000 x 1500 canvas exports as a 40 x 40 file, not as a mostly empty 2000 x 1500 file. This also means that effects such as a drop shadow extend the bounds. A soft shadow can make the exported file larger than the icon you see.
Export artboards
An artboard is a container with its own size, similar to a separate canvas inside the same document. Artboards suit responsive design. For example, one artboard can be 1440 px wide for desktop, one 768 px for tablet, and one 390 px for phones.
To create artboards, choose the Artboard tool, which is nested under the Move tool. Then draw one, or use Layer > New > Artboard from Layers to wrap existing layers. Name each artboard clearly, because the name becomes the file name.
To export them, choose File > Export > Export As. With artboards in the document, the left side of the dialog lists them. Select one or several. Settings you change apply to the items you have selected. Click Export All to write every artboard in one pass.
Some details to remember:
- Content outside an artboard's edges is clipped in the output.
- Artboards cannot be nested inside one another.
- A layer that is not inside an artboard is not part of an artboard export.
- The file name comes from the artboard name. Duplicate names get a numeric suffix.
Generate Image Assets
Generate Image Assets watches your document and writes files whenever you change a layer. You switch it on at File > Generate > Image Assets. After that, the layer name is the export instruction. Photoshop reads the name and writes the file into a folder named after the document, with the suffix -assets. If the document is landing.psd, the folder is landing-assets next to it.
hero.jpg90%
icon-search.png
icon-search-2x.png
200% badge.png
300x300 avatar.jpgEach line is one layer name. The parts are read like this:
| Layer name | Result |
|---|---|
| `hero.jpg90%` | A JPEG at 90% quality. |
| `icon-search.png` | A PNG at the layer's current size. |
| `icon-search-2x.png` | A separate PNG file. Photoshop treats `-2x` as part of the name, not as a scale. See the next section. |
| `200% badge.png` | A PNG at twice the layer's size. |
| `300x300 avatar.jpg` | A JPEG scaled to 300 x 300 px. |
The extension sets the format. Supported ones include .jpg, .png, .gif, and .svg. An optional number directly after the extension sets quality. For JPEG it is a percentage such as 90%. For PNG you can write png8, png24, or png32 to choose the bit depth.
You can also put several outputs in one layer name by separating them with commas, with no spaces around the commas. For example, logo.png, logo.svg writes both formats. Layer names with scale prefixes, such as 200% [email protected], write the 2x file with a name you chose.
Produce 1x and 2x files from one layer
Because the -2x suffix is only text, you have two reliable ways to make a pair of files. The first is to use a scale prefix for each output in one name:
100% icon-search.png, 200% [email protected]This creates icon-search.png at the layer's size and [email protected] at twice that size. For the 2x output to be sharp, the source layer must already be at the 2x size or be a Smart Object or vector shape. Scaling a small raster layer up gives a soft result.
The second way is to build the layer at the largest size you need and let Photoshop scale down. Scaling down from one large source is safe. Scaling up is not.
Convert layers into reusable assets
If you want to export the same layer repeatedly with different settings, convert it to a Smart Object first. A Smart Object keeps the original pixels or vectors, so resizing it does not permanently degrade it. Open Layer > Smart Objects > Convert to Smart Object. Then apply any scale in the export step. You can scale up a vector-based Smart Object (for example, one made from a pasted Illustrator shape) without blur.
How the export flow fits together
Common errors
- Nothing is written. Generate must be switched on in File > Generate > Image Assets. Also check that the document is saved. Photoshop needs a saved file to know where to put the
-assetsfolder. - Wrong file size. A drop shadow, stroke, or Outer Glow extends the layer's bounds. Turn off the effect or rasterize the layer and trim it.
- Blurry 2x file. The source was a raster layer at 1x. Rebuild it at 2x or use a Smart Object or shape layer.
- Illegal characters in names. Characters that are not valid in file names, such as
/,\,:,*,?,",<,>, and|, may be removed or may cause the asset to be skipped. Use letters, numbers, hyphens, and underscores. - Names collide. If two layers produce the same file name, one overwrites the other. Keep names unique across the whole document.
- Spaces in the middle of names. A space separates a scale prefix from the name. Avoid extra spaces elsewhere in the name, and prefer hyphens in web file names.
Check what you exported
Before you hand off the assets, open the output folder and verify the following.
- The file count matches what you planned.
- Each file's pixel dimensions match the target. Check them with File > Open and then Image > Image Size.
- Transparency is still there for PNG files, and no stray halo shows on a dark background.
- Files meant for the web are in sRGB and have an acceptable size.
The pages and snippets that use the files need correct dimensions as well. When you ship two widths of one image, the browser picks between them with srcset and sizes:
<img
src="photo-800.jpg"
srcset="photo-800.jpg 800w, photo-1600.jpg 1600w"
sizes="(max-width: 800px) 100vw, 800px"
width="800" height="533"
alt="Describe the photo">Here photo-800.jpg and photo-1600.jpg are two exports of the same artwork at 1x and 2x widths. The width and height attributes reserve space before the image loads, which prevents layout shift.
Exercise
A layer named 200% badge.png is a 60 x 60 px raster layer. The exported badge looks soft on a high-density screen. What is the likely cause, and what is the fix?
Show answer
The 200% prefix scales the 60 x 60 px raster layer up to 120 x 120 px, and enlarging raster pixels adds no detail, so the result is soft. Rebuild the badge at 120 x 120 px, or convert it to a Smart Object or shape layer so it scales cleanly. Alternatively, make the source the largest size you need and scale down with percentages.
Exercise
You want one file per screen size for a design with 1440 px, 768 px, and 390 px layouts, and you do not want the files to re-export on every edit. Which method fits, and how do the file names get chosen?
Show answer
Use three artboards with Export As, selecting all of them and clicking Export All. Each artboard's name becomes the file name, so name them clearly before exporting (for example home-desktop, home-tablet, home-mobile). Generate Image Assets would work too, but it re-exports automatically as you edit, which you said you do not want.