Automator Pixelmator

Discuss and share Pixelmator Pro resources such as templates, mockups, and tutorials.
User avatar

2021-03-05 00:41:43

I am trying to automate the following process if possible:

I have a images as layers,
I want to "export for web" as jpg at 0.5x with the name of the layer name and have a suffix added to each image.
image size needs to be 2400 x 2400 72 dpi.

Is there a way to do this?

The bigger picture, I want to import lets say 100 images at a time, and then have this automation process automatically save the images in a designated folder
User avatar

2021-03-10 13:32:36

Hi! That's an interesting workflow and it looks like it asks for a few, slightly more complex commands than the ones available in Automator at the moment. You should be able to automate this process using AppleScript, though.
If I understood everything correctly, you're looking to export the layers of a document as individual images at 0.5x scaling, appending each one with a "@0.5x.jpg" suffix? If that's the case, you could try running the following script when you have the desired document open in Pixelmator Pro:
tell application "Pixelmator Pro"
	set exportLocation to choose folder with prompt "Please select where you'd like export the images:"
	repeat with currentLayer in layers of the front document
		export for web currentLayer to file (((exportLocation as text) & name of the currentLayer) & "@0.5x.jpg") as JPEG with properties {compression factor:100, scale:50}
	end repeat
	display notification (number of layers of the front document as text) & ¬
		" layers have been successfully exported." with title "Export completed"
end tell
Let me know if it works for you or if there's anything you'd like to adjust. :)
User avatar

2021-04-10 09:54:32

Hi Aurelija, I hope it is OK to add to this thread. This is almost exactly what I need, but I can't quite work out how to edit it to achieve what I want.

I am hoping there is a way to include the background layer with each other layer.

i.e.

I have layers:
A (30x30px)
B (25x10px)
C (40x10px)
BG (50x50px)

I'm hoping I can somehow change the script to export 3 files: A+BG, B+BG & C+BG where each would be the size of the background, 50x50.

Any help would be amazing.

Thanks

Mitchell
User avatar

2021-04-14 11:18:51

Hey Mitchell. Your workflow is a bit trickier as you'd need to perform four different exports (hiding unnecessary layers in between each one), but it's also doable. Here's a script you can try:
tell application "Pixelmator Pro"
	set exportLocation to choose folder with prompt "Please choose where you'd like to export the images:"
	tell the front document
		set visible of every layer to false
		set visible of the last layer to true
		repeat with currentLayer in every layer
			set visible of currentLayer to true
			export for web to ((exportLocation as text) & name of currentLayer & "@0.5x.jpg") as JPEG with properties {compression factor:100, scale:50}
			set visible of currentLayer to false
		end repeat
	end tell
end tell

Let me know if it works!
User avatar

2021-04-15 05:29:39

Perfect, thank you very much Aurelija - this will save me a lot of time.
User avatar

2021-04-15 13:39:52

Happy to help!