先用pip安装 psd_tools
from psd_tools import PSDImage
from os import path
psd = PSDImage.open('test.psd')
def extractLayerImge(layer):
layer_image = layer.composite()
layer_image.save('folderPath/%s.png' % layer.name)
for layer in psd.descendants():
print('descendants ',layer)
extractLayerImge(layer)