Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Converting layers of Photoshop files to separate PNGs
#!/usr/bin/env python3
""" Get all the PSD files in this directory and
export every layer as a separate PNG.
Using imagemagick.
"""
from glob import glob
import subprocess
for psdfile in glob('*.psd'):
print(psdfile)
# find out number of layers
layers = subprocess.check_output([
'identify', '-format', '%[scene] ', psdfile
]).decode('utf-8').strip().split(' ')
# export layers, adding -<layernumber>.png for file name
for layer in layers:
subprocess.call([
'convert',
psdfile + '['+ layer +']',
psdfile + '-' + layer + '.png'
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.