Created
September 12, 2019 21:25
-
-
Save despens/5c95ebe086e4bfde8b638e91204fed29 to your computer and use it in GitHub Desktop.
Converting layers of Photoshop files to separate PNGs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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