I have 40 Photoshop files and I need to copy the top layer on all of them and paste those layers into one Photoshop file. The second, background layer is the same in all files so I only need it once.
I have tried psd-tools but their documentation says they don’t support copying layers. I tried comtypes.client as suggested here but it just opened the files, I could not get it to copy and paste anything. Now I am trying to work with PIL (pillow) but I am not sure how to get it to copy and paste a layer rather than the whole image. I found this and from that I have the code below but it just returns an empty list and I am not sure where to go from there to get it to copy the layer I need.
import os
from PIL import Image, ImageSequence
image = Image.open("Baroccip1 - Drawing 1.psd")
layers = [frame.copy() for frame in ImageSequence.Iterator(image)]
From 40 files with two layers each I need to get one file with one background layer, and 40 pasted layers from the 40 files. If someone could help me finish the PIL code to copy layers that would be great but any other solutions are also highly appreciated.
2
Answers
You can do this using one of Photoshop’s native scripting languages.
Here’s how you would do it with Javascript:
Here’s a sample code, copy/paste objects in Python, taken from https://github.com/lohriialo/photoshop-scripting-python/blob/master/CopyAndPaste.py