Python PSD layers?
Use Gimp-Python? http://www.gimp.org/docs/python/index.html
You don't need Photoshop that way, and it should work on any platform that runs Gimp and Python. It's a large dependency, but a free one.
For doing it in PIL:
from PIL import Image, ImageSequence
im = Image.open("spam.psd")
layers = [frame.copy() for frame in ImageSequence.Iterator(im)]
Edit: OK, found the solution: https://github.com/jerem/psdparse
This will allow you to extract layers from a psd file with python without any non-python stuff.
You can use the win32com for accessing the Photoshop with Python. Possible pseudo code for your work:
- Load the PSD file
- Collect all layers and make all layers VISIBLE=OFF
- Turn one layer after another, mark them VISIBLE=ON and export to PNG
import win32com.client pApp = win32com.client.Dispatch('Photoshop.Application') def makeAllLayerInvisible(lyrs): for ly in lyrs: ly.Visible = False def makeEachLayerVisibleAndExportToPNG(lyrs): for ly in lyrs: ly.Visible = True options = win32com.client.Dispatch('Photoshop.PNGSaveOptions') options.Interlaced = False tf = 'PNG file name with path' doc.SaveAs(SaveIn=tf,Options=options) ly.Visible = False #pApp.Open(PSD file) doc = pApp.ActiveDocument makeAllLayerInvisible(doc.Layers) makeEachLayerVisibleAndExportToPNG(doc.Layers)