Fixing "Image Events" AppleScripts Broken in macOS 10.15 Catalina

24 November 2019

Image asset resizing is a common operation carried out by developers when building iOS applications. Perhaps not all of the icons in your application can be represented using vector graphics, so 1×, 2×, and 3× representations need to be created to support various different Retina Display configurations. Also, at the time of writing, every application needs 18 differently sized variations of its icon to be provided in order to support notifications, the application's entry in the Settings app, and search results in the iOS spotlight UI. That's an awful lot of image resizing!

It makes sense to save both time and sanity by automating these resizing operations. Fortunately an application called Image Events is provided by macOS for exactly this purpose, and gives developers access to the power of the Core Image framework directly from AppleScript. This makes it trivial for developers to build simple scripts to handle these repetitive image resizing operations whilst utilising a high-quality image manipulation framework. Let's take a look at a simple example of how this works:

-- Launch Image Events
tell application "Image Events"
    -- Open a previously specified image file
    set theImage to open theImageFile
    -- Scale the image to 50% of its original size
    scale theImage by factor 0.5
    -- save the changes
    save theImage with icon
end tell

This script fragment uses the Image Events application to scale an image down to 50% of its original size, then saves the image.

However, as of macOS 10.15 Catalina, this script won't work. Despite the user being prompted when your script is first run to grant the necessary permissions required by Image Events, you will find that your image is not resized. You also won't find anything helpful in the system console - the operation simply does not work.

After much head scratching, I eventually figured out the solution. The problem is that despite the permission prompts, Image Events does not actually have all of the permissions that it needs to save the result of the image manipulation operations that it has in fact executed successfully. The solution, mercifully, is a straightforward one.

First, launch System Preferences and navigate to the Security and Privacy pane. Click the Privacy tab, scroll down the menu on the left, and click on Full Disk Access. Click the + icon in the right hand box, and navigate to System > Library > Core Services. Select Image Events, and click the Open button.

The Security and Privacy System Preferences pane showing Image Events with the Full Disk Access permission.
The Security and Privacy System Preferences pane showing Image Events with the Full Disk Access permission.

Image Events now has the permissions it needs to write images out to disk. Your image resizing workflows will work again, and you can get back to building great new features for your users instead of cursing the infernal conundrums of Catalina.