AppleScript Image Events

by brian d foy

Related link:

Now that I have Panther, I can play around with Image Events. Prior to this, I used Perl to read in an image from my phone, scale it to 320x240, then add a black border around the image.

Now AppleScript makes this really easy. Cobbling together a couple of scripts from the Apple web site, I get the job done in a very Mac like way.

set this_file to choose file

tell application "Image Events"
set this_image to open this_file
scale this_image to size 318
pad this_image to dimensions {320, 240}
save this_image with icon
close this_image
end tell

on error error_message
display dialog error_message
end try

Although this script asks me to choose the file through a dialog, Apple also shows examples of automatically choosing every image in a directory, on the desktop, and so on. I want to set up a folder for incoming images for a moblog, then automically run an AppleScript on every new photo before it gets posted to the web.

At some point I also want to use Image Events with watch folder for iPhoto, so when I take screenshots I can automatically convert them from PDF to JPEG. I just wish I could automatically import the images, though.

Still, someone at Apple finally did something did something good for AppleScript.

Do you use image events?


2004-05-16 12:03:28
It's "AppleScript", fwiw. Either way, though, I prefer using Imager or calling convert(1).
2004-05-16 14:21:03
I can never remember which things I need to uppercase, even though you keep telling me. :)

I use Imager and ImageMagick too, but not every one has those or wants to deal with them. AppleScript Image Events comes with Panther :)