Can AppleScript work with clipboard images?

Can AppleScript create and also manipulate clipboard images? For example, can it create a bitmap image like KM can do here:


Also, can AppleScript do more with image clipboards like flip, rotate, resize, crop, save, trim, etc.?

I'm hitting some limits with the KM image actions, and I'd like to know if AppleScript has more power with images. I did google this topic, but found no answer, which may mean it's not possible.

Not natively. You could control Keyboard Maestro from AppleScript to manipulate images, but obviously that would give you no more power.

Alternatively, you could control some other scriptable application, or a shell tool. I used to use ImageMagick for scriptable image drawing, but it was always a pain to install, maybe it is better now.

Long ago I wrote an document on different ways to do Scripted Image Drawing. It's likely wildly out of date now, but it might have some leads.

Thanks. Hmmm... if I did that, would I gain the ability to refer to clipboards by a name stored in an AppleScript variable? Because the one thing I miss the most is the ability to "pass clipboard names to a macro."

Do you mean access Named Clipboards by name?

You can get the value of a named clipboard into the system clipboard or another specific named clipboard using the Filter action.


You can specify specific named clipboards by executing the XML of an action from AppleScript, eg:

set xml to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"\">
<plist version=\"1.0\">
tell application "Keyboard Maestro Engine" to do script xml

You can adjust the names in the XML as with any string in AppleScript.

Does that filter do the same thing as this action...?


It seems to work with text-only clipboards. What I wanted was a variable that could pass the name of a clipboard that contained an image, not text.

It will take me a while to figure out what that XML does, perhaps that will help me.

As for ImageMagick, I found it to be 100 times slower at processing images than I had hope for. And about 10 times more complicated than I had hoped for. But it can do amazing things, some of which I would love to see KM do in the future.

No. It reads the name of the clipboard from the input source, and then gets the specified named clipboard, which can be text or non-text depending on the output destination.

Yes, either of the actions I showed above will work with non-text clipboards.