Automate exporting layer groups to images possible?

Talk about Pixelmator Pro, share tips & tricks, tutorials, and other resources.
User avatar

2021-06-17 18:47:14

One of the things that really helps me in Photoshop is I found a script that can export layer groups as individual files with just one click. For example each group is a thumbnail image for a different show I work on. If I have 10 groups for 10 episodes, then running the script will export 10 png or jpeg files for me with just one click.

Is there any way to do something similar in Pixelmator Pro?
User avatar

2021-06-17 21:26:19

Select all the groups you want to export, then ⌃ (Control) click on any of them, at the bottom of the list, click 'Add for Export'
this should open the Export for Web tool, all you really need to do now is choose the format you would like to export in, and hit 'Export...'!
Give it a go!
User avatar

2021-06-21 14:56:07

Yep, I'd go with what Tali suggested. Or if you're looking to automate this completely and you're also familiar with scripting, you also can try running the following AppleScript script in the Script Editor app on your Mac:
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 & ".jpg") as JPEG with properties {compression factor:100}
			set visible of currentLayer to false
		end repeat
	end tell
end tell
This script exports all layers or entire layer groups in your document as individual JPEG images to a selected folder on your Mac. You can, of course, make improvements (change image scaling, compression, etc.) based on what you need for your workflow.
User avatar

2021-10-10 01:17:35

Yep, I'd go with what Tali suggested. Or if you're looking to automate this completely and you're also familiar with scripting, you also can try running the following AppleScript script in the TextEdit app on your Mac:



This script exports all layers or entire layer groups in your document as individual JPEG images to a selected folder on your Mac. You can, of course, make improvements (change image scaling, compression, etc.) based on what you need for your workflow.
Thank you for that script! If I may add a couple of things, the script needs to run into Script Editor (not TextEdit), and it will add the background layer on every other layer, so make a transparent background if you want the other layers transparent.
User avatar

2021-10-11 11:32:53

by floborg
by Aurelija 2021-06-21 21:56:07 Yep, I'd go with what Tali suggested. Or if you're looking to automate this completely and you're also familiar with scripting, you also can try running the following AppleScript script in the TextEdit app on your Mac:
This script exports all layers or entire layer groups in your document as individual JPEG images to a selected folder on your Mac. You can, of course, make improvements (change image scaling, compression, etc.) based on what you need for your workflow.
Thank you for that script! If I may add a couple of things, the script needs to run into Script Editor (not TextEdit), and it will add the background layer on every other layer, so make a transparent background if you want the other layers transparent.
Oops! Fixed it — thanks. And good point about creating a transparent background for transparent images. :ok_hand:
User avatar

2021-11-27 17:44:52

You are welcome and thank YOU!
User avatar

2021-11-30 13:58:36

by floborg 2021-11-27 15:44:52 You are welcome and thank YOU!
:pray:
User avatar

2022-09-16 16:35:10

Also all layers need to be ungrouped
User avatar

2022-09-17 17:58:34

I put the above AppleScript text into an automator script as a service. Worked well to call the service to perform the actions. (I don't really do this often or at all but thought the idea should be preserved and available as may someday be needed - called it pixLayerDump.) :blush: