Advanced automation and scripting with AppleScript
Pixelmator Pro includes extensive and full-featured support for AppleScript, the scripting language created by Apple that lets you directly control apps using instructions written in an English-like scripting language.

There are many different ways you can use AppleScript to speed up and enhance your image editing workflows. For example, you can use it to automate repetitive tasks, such as changing the color of the background in, say, 100 images to a specific shade of blue. You can also create workflows that involve multiple applications — for example, if you need to take a set of texts from a Numbers spreadsheet and use them to label a series of images. You can even use AppleScript to extend the functionality of Pixelmator Pro itself, for example by writing a script that creates a 3D text effect using the built-in tools in the app.
AppleScript basics
In this tutorial, we won’t go too in depth into the Script Editor, dictionaries, or the syntax of the AppleScript language, as these are covered on many different websites dedicated to AppleScript. However, we’d like to share a couple example scripts with you and there are a few main pieces of information that should help you understand these scripts and get started with AppleScript in general. We’ll also point you to useful resources if you’d like to learn more about AppleScript itself.
Getting started and opening the Script Editor
To get started with writing, compiling, running, and saving scripts, you’ll need to open the Script Editor app. You can find it in the Utilities folder inside the Applications folder. You can also use Spotlight to search for “Script Editor” and open it that way.

Finding the Pixelmator Pro dictionary
Along with the standard AppleScript terms, every scriptable application has its own dictionary with the words and phrases specific to a particular app. To open the dictionary for Pixelmator Pro, choose File > Open Dictionary, then find Pixelmator Pro and click Choose.

In the Pixelmator Pro dictionary, you’ll find various example scripts that show you how to use each of these app-specific terms.
AppleScript syntax fundamentals
AppleScript syntax is heavily based on English syntax, so even if you have no programming experience, you can often find out what a script does by simply reading it. We won’t delve too deep into AppleScript syntax as there are many resources that focus on this, but there are a few basic concepts that should help you understand the example scripts in the following section of the tutorial.
The Tell Block
You use the ‘tell’ phrase to tell an application what you want it to do. In fact, that’s the very first word of many simple scripts. An empty application tell block looks like this:
tell application "Pixelmator Pro"
--Your instructions would go here
end tell
Inside the tell block, you place the commands you’d like Pixelmator Pro to execute.
Object Hierarchy
There is a set hierarchy of objects, starting with the application object at the top. To edit an object, you have to tell that specific object to change something. As the hierarchy starts with the application object, when writing scripts for Pixelmator Pro, the first phrase will always be:
tell application "Pixelmator Pro"
When you want to make changes to a specific layer inside a specific document, you’ll need to make sure you’re targeting it. There are different ways to do this, but here’s one simple example that sets the stroke width of the first layer in the current document to 5 pixels using a number of nested tell blocks:
tell application "Pixelmator Pro"
tell its front document
tell its first layer
tell its styles
set the stroke width to 5.0
end tell
end tell
end tell
end tell
The basic Pixelmator Pro hierarchy is: Application > Documents > Layers > Effects.
First, you specify which application you’re instructing. Then, the application may have multiple documents, so you need to say which one you’d like to edit. A specific document can also have a number of different layers, so you need to say which layer you’d like to edit, and how you’d like to edit it. Finally, layers can also contain effects. Note that color adjustments and styles are properties of layers, rather than separate objects contained by layers.
AppleScript is a very flexible language, so you can also write the command above like this:
tell application "Pixelmator Pro"
tell the styles of the first layer of the front document to set the stroke width to 5.0
end tell
Or even:
tell application "Pixelmator Pro"
tell the front document's first layer's styles to set the stroke width to 5.0
end tell
Note how, in both cases, you’re still navigating down the hierarchy to the object you’d like to edit and, in this case, you’re changing one of its properties.
Along with setting properties, you can also use verbs such as ‘select’ to perform actions. Like this:
tell application "Pixelmator Pro"
select every layer of the front document
end tell
Color adjustments and layer styles are properties of layers, so you can use the syntax above to edit them. Each layer will always have these properties and they will be editable.
Effects are a little different. They are elements that are contained by layers or layer masks. In the same way that a number of different layers might belong to a document, a number of different effects might belong to a layer and these need to be created using the standard ‘make’ verb. Here’s the basic syntax:
tell application "Pixelmator Pro"
tell its front document
tell its first layer
make new gaussian effect at the beginning of effects with properties {radius:5}
end tell
end tell
end tell
A few example scripts
For some inspiration, here are a few example scripts, showing the kinds of things you can do with AppleScript and Pixelmator Pro.
The first script is a very basic script that will make Pixelmator Pro show an alert containing the phrase “Hello, world!”.
tell application "Pixelmator Pro"
display alert "Hello, world!"
end tell

Last updated