To convert a PSD to PNG from the command line, the command you want is magick "design.psd[0]" design.png. The [0] is the whole trick: it selects the merged, flattened composite that Photoshop saves inside every PSD, so you get a single PNG of the artwork as it looked in Photoshop. Leave the [0] off and ImageMagick treats each layer as a separate image and exports them all, which is the classic surprise that sends people back to search.
magick "design.psd[0]" design.pngNo Photoshop required. ImageMagick reads PSD natively. On ImageMagick 7 the command is magick; on older 6.x installs it is convert (convert "design.psd[0]" design.png), and convert still works as a compatibility shim on 7. The quotes around the filename matter: the square brackets in design.psd[0] are glob characters in most shells, so quoting keeps the shell from mangling them.
Why the [0] matters
A PSD is not one image. It is a stack of layers, plus a pre-rendered flattened version of the whole thing that Photoshop bakes in when it saves. ImageMagick exposes each of those as an indexed frame, the same way it treats the frames of an animated GIF:
design.psd[0]is the merged composite: the artwork as you see it in Photoshop, every layer combined.design.psd[1],design.psd[2], and up are the individual layers.
So magick design.psd design.png (no index) is really "export every frame," and ImageMagick obliges by writing design-0.png, design-1.png, design-2.png, one per layer. That is occasionally what you want, but if you searched for "PSD to PNG" you almost certainly wanted one flat image, and [0] is how you ask for it.
Extract a single layer, or every layer
The same index that gives you the composite gives you any individual layer. Want layer 2 on its own?
magick "design.psd[2]" layer2.pngTo deliberately export every layer to its own numbered PNG, point ImageMagick at the PSD with no index and use a %d placeholder in the output name:
magick design.psd layer-%d.pngThat writes layer-0.png (the composite), layer-1.png, layer-2.png, and so on. This is the same [index] selection trick that pulls the first frame out of an animated GIF, so if you have used magick "clip.gif[0]" first-frame.png before, you already know this pattern.
-flatten as the alternative
If you would rather have ImageMagick rebuild the composite from the layers itself instead of reading Photoshop's saved one, use -flatten:
magick design.psd -flatten design.pngThis merges all layers down onto the background and writes a single PNG. In practice [0] and -flatten land on the same result for most files, but they get there differently: [0] reads the composite Photoshop already saved, while -flatten composites the layers in ImageMagick. When a file has layer masks or unusual blend modes, the two can diverge, and the saved composite ([0]) is usually the more faithful match to what you saw in Photoshop. Reach for -flatten when [0] looks wrong or the composite is missing.
PNG keeps an alpha channel, so [0] preserves the composite's transparency as long as the PSD had it. If a stray background creeps in, force the canvas transparent with magick "design.psd[0]" -background none -alpha on design.png.
Batch a whole folder
To convert a directory of PSDs, loop over them and take the composite from each:
for f in *.psd; do
magick "${f}[0]" "${f%.psd}.png"
done${f%.psd}.png strips the .psd extension and adds .png, so hero.psd becomes hero.png. For very large PSDs, cap memory with -limit if a batch run balloons, for example magick -limit memory 2GiB "${f}[0]" out.png.
The honest limitation: Maximize Compatibility
Here is the catch worth knowing before you trust a batch run. ImageMagick reads the saved composite for [0], and that composite is only guaranteed to be present and correct if the file was saved from Photoshop with Maximize Compatibility turned on (Photoshop's "Maximize PSD and PSB File Compatibility" preference). With it on, Photoshop writes that flattened preview into the file and [0] renders exactly what you designed.
With it off, the saved composite may be stale or missing, and a PSD that leans on adjustment layers, smart objects, or non-trivial blend modes can render wrong: washed-out color, missing effects, or a result that does not match Photoshop. ImageMagick reads the file rather than running Photoshop's rendering engine, so anything Photoshop computes at display time that was not baked into the saved composite will not be reproduced. There is no flag that fixes this; the fix is to re-save the PSD with Maximize Compatibility on. It is the single most common reason a command-line PSD conversion comes out looking off, and it is not an ImageMagick bug.
On macOS: sips reads PSD too
If you are on a Mac and would rather not install ImageMagick, the built-in sips (Scriptable Image Processing System) lists psd among its supported input formats and can write a PNG:
sips -s format png design.psd --out design.pngsips reads Photoshop's saved composite the same way, so the Maximize Compatibility caveat above applies here as well. It has no layer-index concept, so it only ever gives you the flattened image, never individual layers. For anything beyond a quick one-off conversion, ImageMagick is the more capable tool, but sips is genuinely handy when it is already on the machine.
FAQ
See also
- Convert an SVG to PNG from the command line: the vector counterpart, plus why ImageMagick can blur an SVG and how to get a crisp render.
- Convert images to WebP from the command line: once you have a PNG, this is how to ship a smaller, modern format for the web.
- The ffmpeg command cheat sheet: the hub for the rest of the command-line media-conversion toolkit, covering video, audio, and GIFs.
Sources
Authoritative references this article was fact-checked against.
- ImageMagick: Supported image formats (PSD read/write, official)imagemagick.org
- ImageMagick command-line options: flatten (official)imagemagick.org
- ImageMagick Usage: multi-image layers and flatten (official)usage.imagemagick.org

![Convert a PSD to PNG from the command line with ImageMagick using the [0] composite-layer trick, extract individual layers, batch a folder, and the Maximize Compatibility caveat.](https://images.techearl.com/convert-psd-to-png-command-line/convert-psd-to-png-command-line-1536.webp)



