Hello fellow Pixelmators. I've got a script I am trying to automate, basically to make a layer above the current image, name it (if needed), fill it with white color, then move the layer to the bottom of the document (the background), then flatten everything.
This is what I have so far, getting some ideas from this board:
tell application "Pixelmator Pro"
activate
tell front document
set thisLayer to make new layer
set name of thisLayer to "myLayer"
fill layer named "myLayer" with color {255, 255, 255, 255}
end tell
end tell
Thanks for any help you can offer!
(The reason I need to do this is, dragging around an image with transparency behind it and copying only copies the image, not the part with the transparency, as Photoshop would do, I think. So I need to add a background and flatten to avoid unexpected results.)
Applescript question: how would I fill in a layer?
2023-11-11 16:33:03
I solved it myself. What I ended up with was something like
tell application "Pixelmator Pro"
activate
tell front document
set thisLayer to make new layer
set name of thisLayer to "myLayer"
fill layer named "myLayer" with color {65535, 65535, 65535} -- white
repeat with a from 1 to number of layers
move layer (number of layers) to before layer a
end repeat
merge all
end tell
end tell
This basically creates a white layer above my image, then moves it below my image then flattens everything, so I can avoid the problem of my selection not being "selected" if there was no background image over that part of my document.
Hope this is helpful to anyone.
tell application "Pixelmator Pro"
activate
tell front document
set thisLayer to make new layer
set name of thisLayer to "myLayer"
fill layer named "myLayer" with color {65535, 65535, 65535} -- white
repeat with a from 1 to number of layers
move layer (number of layers) to before layer a
end repeat
merge all
end tell
end tell
This basically creates a white layer above my image, then moves it below my image then flattens everything, so I can avoid the problem of my selection not being "selected" if there was no background image over that part of my document.
Hope this is helpful to anyone.