Extract PSD Layers with Bash and ImageMagick
ImageMagick can read many Photoshop PSD files and export the images it exposes as frames or layers. Combined with a Bash loop, this can automate batch extraction without opening every file manually.
Install ImageMagick
On Debian/Ubuntu:
sudo apt install imagemagickImageMagick 7 uses the magick command. Some older installations expose commands such as convert directly.
Extract One PSD
mkdir -p output
magick input.psd output/layer-%03d.pngWhen ImageMagick exposes multiple images from the PSD, the numbered output pattern prevents them from overwriting one another.
PSD support varies with file features. Complex Photoshop effects, adjustment layers, masks, smart objects, or unsupported color modes may not reproduce exactly as they do in Photoshop.
Batch Script
#!/usr/bin/env bash
set -euo pipefail
if (($# == 0)); then
printf 'Usage: %s FILE.psd [FILE.psd ...]\n' "$0" >&2
exit 1
fi
if ! command -v magick >/dev/null 2>&1; then
echo 'ImageMagick 7 (magick) was not found in PATH.' >&2
exit 1
fi
for input_psd in "$@"; do
filename=$(basename -- "$input_psd")
name=${filename%.*}
output_directory="image/$name"
mkdir -p "$output_directory"
magick "$input_psd" "$output_directory/layer-%03d.png"
printf "Exported images from '%s' to '%s'.\n" \
"$input_psd" "$output_directory"
doneRun it with:
chmod +x extract_psd.sh
./extract_psd.sh file1.psd file2.psdInspect the PSD First
Before a large batch, check what ImageMagick sees:
magick identify input.psdThis can reveal the number of images/frames and basic properties before extraction.
Conclusion
Bash plus ImageMagick can automate PSD image extraction effectively when the PSD features are supported. Use numbered output filenames, test representative files first, and verify the exported images before relying on the workflow for production assets.