I am looking for an example to create an image with python ImageMagic Wand with named layers. How do you set the Layer names for a photoshop (PSD) file?
```# Create Image (Layer0)
with Image(
width=int(configuration['layer0']['width']),
height=int(configuration['layer0']['height']),
background=Color('Lime'),
format='psd'
) as boxcover:
boxcover.iterator_first()
boxcover.pseudo(4096,2048, 'xc:gold')
with Drawing() as layer:
layer.font_size = 72
layer.font_family = 'Arial'
layer.text(100,100,'Hello')
layer.draw(boxcover)
boxcover.iterator_set(1)
boxcover.pseudo(4096,2048, 'xc:purple')
debug_layers(boxcover,'/Users/colin/Downloads/debug.png')
boxcover.save(filename='/Users/colin/Downloads/test1.psd')
```
I don't have much experience with PSD format, but with wand, you would need to set the 'label'
property (Image.options['label']
) before reading / creating a new layer.
with Image(width=4096, height=2048, pseudo='xc:lime') as boxcover:
boxcover.options['label'] = 'First Layer'
boxcover.pseudo(4096,2048, 'xc:gold')
with Drawing() as layer:
layer.font_size = 72
layer.font_family = 'Arial'
layer.text(100,100,'Hello')
layer.draw(boxcover)
boxcover.options['label'] = 'Second Layer'
boxcover.pseudo(4096,2048, 'xc:purple')
boxcover.save(filename='test1.psd')
And we can verify with identify
utility.
$ identify -format '%[filename] %[page] %[label]\n' test1.psd
test1.psd 4096x2048
test1.psd 4096x2048 First Layer
test1.psd 4096x2048 Second Layer