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
We have some important news to share: the Pixelmator Team plans to join Apple. If you need product support please contact us here.
Learn moreNeed some help with Applescript layer resize
The Pixelmator Community has been archived and cannot accept new posts or comments.
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-11 16:56:01
chatGPT was of little help. All the methods it suggested failed for one reason or another. I am not any kind of applescript user.
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
2023-12-14 22:39:28
I don't think this changes the origin - Just saying. Moves the origin to a different location based on the calculated midpoint. It would be VERY good if PixPro would permit changing the origin of a layer/shape or group, etc.
This is a good work around that shortcoming.
This is a good work around that shortcoming.