I've been trying to see if I can speed up a part of a pipeline where we're atlassing images (previously using Photoshop which is horrendously slow due to GUI updates) and I'm looking to see if I can use Pillow to create a tiff atlas.
Now I know I can make an atlas out of images (have this working already) in Pillow but I can not for the life of me get it to have the images as layers so that way if someone needs to edit (move images around for example) at a later date they can easily do so.
from PIL import Image
import os
cwd = os.getcwd()
atlas = Image.new('RGBA', (2048, 2048),(0,0,0,0))
tgas = [x for x in os.listdir(cwd) if x.lower().endswith(".tga")]
count = 0
imgs = []
for img in tgas:
print(img)
im = Image.open(img)
temp = Image.new('RGBA', (2048, 2048),(0,0,0,0))
if count == 0:
atlas.paste(im,(0, 0))
elif count == 1:
atlas.paste(im, (1024,0))
elif count == 2:
atlas.paste(im, (0, 1024))
elif count == 3:
atlas.paste(im, (1024,1024))
count +=1
imgs.append(atlas)
im.close()
atlas.save("atlasTest.tif", tags="37724", compression="None", save_all=True, append_images=imgs)
I found another SO post about the reading of tiff to see if it has layers (hence the tags="37724" )but it does not seem to work on save.
This method would save a ton of time but I don't think I can use it if I can't get the layers. I originally was going to try to make it save out the atlas'd images to a PSD but can't seem to make layers in that either... Was able to also do "multi-page" but that doesn't seem to be what I'm looking for either, it really would have to be layers just cause it would be easier to deal with later on. Any help would be great (Also, please don't judge my hard coded image placement, was done quickly as a test and didn't feel like doing the math for it :P )