Hello,
Is the Image Events application still working?
Even with Sal Soghoian’s explanations, I’m having a hard time getting it to work with even very simple commands.
I just need to resize an image.
I know how to do it using Photoshop, but I wanted to do it invisibly in the background, like Image Events allows.
Every time I request information about the image, I always get the same warning: “Il est impossible d’obtenir dimensions of missing value.” (in French for me).
Traduction : “It is impossible to obtain dimensions of missing value.”
I don’t have access to any information about the selected image.
Yet, so far it’s really simple.
Any ideas?
Example :
(Sorry I couldn’t integrate the program properly when pasting it, I don’t know why…)
tell application “Finder”
set this_file to choose file without invisibles
end tell
try
tell application “Image Events”
– start the Image Events
application launch
– open the image file
set this_image to open this_file
– get dimensions of the image
copy dimensions of this_image to {W, H}
display dialog W & " " & H
close this_image
end tell
on error error_message
display dialog error_message
end try
It seems that Apple hasn’t updated its documentation. Image Events now seems to need a POSIX path - or at least, it works with a POSIX path. Also, I think the display dialog
command needs to be outside the tell block because Image Events doesn’t allow user interaction. But I’m just guessing. Whether or not I’ve got the reasons right, this seems to work from Script Debugger.
When I first saved the script as an applet it gave the error message “Not authorized to send Apple events from Image Events.” I seem to have fixed that by saving the applet again from SD, replacing the original one.
tell application "Finder"
set this_file to choose file without invisibles
set this_file to POSIX path of this_file
end tell
try
tell application "Image Events"
-- start the Image Events
launch
-- open the image file
set this_image to open this_file
-- get dimensions of the image
copy dimensions of this_image to {W, H}
close this_image
end tell
tell me to activate
display dialog (W as string) & " " & H as string
on error error_message
display dialog error_message
end try
1 Like
Thank you very much Emendelson!
I tried everything I could think of, changing so many parameters, but I absolutely forgot to change the link to a Posix file! Well done! It works great now.
You’re right about the Display dialog; it’s a bad idea. I added it at the end to check, but the program stopped beforehand anyway 
Oops! Correction! I don’t understand!
This solution worked great the first time I tried it, and now it doesn’t work at all. I restarted the Mac, and it worked once, and then it stopped. I don’t understand what’s going on…
Are you running it from SD or as an Applet? If as an applet, try exporting it again from SD. Otherwise, I have no idea of what might be wrong.
I just found the solution:
You need to find the Images Events application and then grant permissions in the system settings!
To allow Image Events to access the entire disk, go to System Preferences > Security. Then, select “Full Disk Access” and add the Image Events application to the list of applications allowed to access the entire disk. The Image Events application is cleverly hidden in the System > Library > CoreServices > Image Events.app directory.
Thanks for your help anyway!