The following online materials, regarding the manipulation of images using the Image Events application, are exerpted from the Apple Pro Training Book AppleScript 1-2-3.

Image Events

The world of the modern computer user is filled with pictures. Images from the internet, images in your mail messages, images from your cellphone, images from your camera-they're everywhere. Manipulating and sharing images is a big part of what we do with our computers. Most scripters don't realize that Mac OS X includes powerful built-in scriptable image processing tools that work independent of any photo software. In this chapter you'll learn how to scale, crop, rotate, pad, flip, and convert images, and you don't need anything but AppleScript.

The Big Picture

Not to bore you with the details, but it may be useful to know the story behind the story... Mac OS X contains an image processing framework called "Core Image." This framework is responsible for most of the image processing done by the operating system and software such as iPhoto or Aperture. The power of this framework is made available to shell scripts through a command-line utility called SIPS (Scriptable Image Processing Server). Another interface to this utility is a small application in the System > Library > CoreServices folder named Image Events.

Image Events - the Application

The Image Events application is used by AppleScript to control the SIPS architecture. It has no visual interface and presents no menus, windows, or dialogs for user interaction. It is intended to run invisibly as a background process, only accessible via AppleScript commands.

The scripting dictionary for Image Events, detailing its scriptable objects and commands, can be accessed from the Library palette in the Script Editor application.

The script suites included in the Image Events dictionary are:

  1. Standard Suite. This suite includes the standard objects and commands used by most scriptable applications. However, unlike other applications, Image Events runs as an invisible process with no user interface, so only a few commands from this suite, such as close and quit, are relevant.
  2. Text Suite. This default suite is included in most scriptable applications and is used for manipulating text objects. Since Image Events does not currently support any text classes, this suite is not used.
  3. Disk-Folder-File Suite. This suite is used for locating files and folders on disk. The classes and commands from this suite make it possible to locate, open, or delete files and folders using the Image Events application instead of the Finder.
  4. Image Suite. This suite contains the properties and commands for manipulating image files.
  5. Image Events Suite. This suite contains the properties of the Image Events application itself.

Let's examine some practical uses of the Image Events application, by focusing on the Image Suite.