This works, but it makes the layer shrink as if the anchor point were in the upper left corner. Is there any more elegant way to do this, so that it shrinks from the center? Or, how would I set the X/Y point of a layer if I wanted to move the layer over in the script?set resizeType to 1 -- resize 5%
--set resizeType to 2 -- resize 15%
tell application "Pixelmator Pro"
tell document 1
set thisLayer to current layer
set theWidth to width of thisLayer
set theHeight to height of thisLayer
if resizeType = 1 then
set width of thisLayer to theWidth * 0.92 -- reduce it a little
end if
if resizeType = 2 then
set width of thisLayer to theWidth * 0.85 -- reduce it a bit more
end if
end tell
end tell
Need some help with Applescript layer resize
2023-12-11 11:56:21
Hello, I *love* Pixelmator Pro and am so happy I switched from that "other" program. I am working on an Applescript (which I'll execute through Keyboard Maestro, a tool every Mac user should be using) that takes the current image layer I'm working on and reduces it in size a little (around 5% to 15% depending on the macro). I managed to get a script that works for me, which is
2023-12-14 22:04:15
Try this tweak to use the midpoint as the anchor instead of the upper left corner.
set resizeType to 1 -- resize 5%
--set resizeType to 2 -- resize 15%
tell application "Pixelmator Pro"
tell document 1
set thisLayer to current layer
set theWidth to width of thisLayer
set theHeight to height of thisLayer
set {itemX, itemY} to position of thisLayer
if resizeType = 1 then
set width of thisLayer to theWidth * 0.92 -- reduce it a little
end if
if resizeType = 2 then
set width of thisLayer to theWidth * 0.85 -- reduce it a bit more
end if
set newWidth to width of thisLayer
set newHeight to height of thisLayer
tell thisLayer to set position to {itemX + ((theWidth - newWidth) / 2), itemY + (theHeight - newHeight) / 2}
end tell
end tell