1

I'm trying to find a way to stack multiple images into layers of a TIFF image so that Photoshop will recognise those images as separate layers in Python. I tried creating multiple pages TIFF as described here But Photoshop only recognises one layer. Also Tried using this code, but also got only one layer

import glob
from PIL import Image
FRAMES = [] 
FIRST_SIZE = None 
OUT_NAME = "test.tiff" 
filelist = glob.glob("photos/*") 
for i in filelist:
    img = Image.open(i)
    FRAMES.append(img)
FRAMES[0].save(OUT_NAME, save_all=True, append_images=FRAMES)

Please help me.

Vkitor
  • 57
  • 7
  • Pages and layers are two different things. Unless things have changed with the last few versions, Photoshop does not support multi-page TIFF files but it does support layered TIFFs. – cybernetic.nomad Apr 05 '18 at 01:51

1 Answers1

0

Port and finish this code or control Photoshop from Python:

from win32com.client import Dispatch

psApp = Dispatch("Photoshop.Application")
psApp.Open(r"C:\Users\Kim-DEV\psd_env\test1.psd") 
doc = psApp.ActiveDocument
layerRef = doc.ArtLayers.Add()

psTextLayer = 2  # from enum PsLayerKind
layerRef.Kind = psTextLayer

textItem = layerRef.TextItem
textItem.Contents = "HELLO WORLD!"
textItem.Position = (120, 120)

Then doc.Save() or export to a different format.

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124