I'm trying to automate a routine in my Pixelmator Pro document.
I have quite a few layers that I need to export for web in different formats, I've tried to write an AppleScript to do this but I cannot get It to work (I've never used AppleScript before, honestly). That's what I have right now..
tell application "Pixelmator Pro"
tell its front document
set numberOfLayers to count layers
set selectedLayer to 1
repeat until selectedLayer = numberOfLayers
select layer selectedLayer
set lName to layer name
set lName to lName + ".jpg"
export for web layer to file ((path to desktop as text) & lName) as JPEG with properties {compression factor:90}
set lName to lName + ".png"
export for web layer to file ((path to desktop as text) & lName) as PNG with properties {compression factor:90, advanced compression:true, keep transparency:true}
set lName to lName + ".webp"
export for web layer to file ((path to desktop as text) & lName) as WebP with properties {compression factor:90, keep transparency:true}
set selectedLayer to selectedLayer + 1
end repeat
end tell
end tell
Script compiles correctly but if I try to run it, it stops at line "set lName to layer name" with error "Unable to get layer "siteImages" of document 1."Does anyone have an idea what's the correct way to do the task?
Thanks.