I’ve been trying to do some simple image manipulation, but I can’t get it to work in Mac Monterey.
In my own script I get the error that Image Events doesn’t have ‘View permissions’. I gave the folder the file is in read & write access, I gave Image Events full folder access in the Security System Preferences…but no luck.
set theImageFile to choose file of type "public.image" with prompt ""
-- Launch Image Events and open the image
tell application "Image Events"
launch
open theImageFile
end tell
It returns ‘missing value’ as the result – according to Apples documentation: “The result of the open command is an image object, the newly opened image” – which makes me wonder if it’s again having permission issues.
madla. In recent versions of macOS, Image Events doesn’t always work with aliases, and the choose file command returns an alias. The following script works on my computer–I modified it to return something (the image dimensions) just for test purposes. So, as a first step, I would suggest that you run this script in a script editor. You can then deal with permissions.
set theImageFile to choose file of type "public.image" with prompt ""
set theImageFile to theImageFile as text
tell application "Image Events"
launch
set theImage to (open file theImageFile)
set {xResolution, yResolution} to dimensions of theImage
close theImage
return {xResolution, yResolution}
end tell
Thank you all, converting the alias into a path or POSIX path solves this issue.
Regarding full disk access. Given Image Events full disk access makes live easier, but doesn’t appear to be necessary as the droplet will request access when run initially.
set imageAlias to choose file of type "public.image"
tell application "Image Events"
launch
set theImage to open (a reference to imageAlias)
set {xResolution, yResolution} to dimensions of theImage
close theImage
return {xResolution, yResolution}
end tell
or:
set imageAlias to choose file of type "public.image"
tell application "Image Events"
launch
set theImage to open item 1 of {imageAlias}
set {xResolution, yResolution} to dimensions of theImage
close theImage
return {xResolution, yResolution}
end tell