Tuesday, May 29, 2007

Framed and Exposed: Better Image Automation Through Scripting

Managing your images can be a tedious time-consuming task. But learning how to harness the power of AppleScript and Image Events can make quick work of renaming, resizing, and rotating your images, along with other essential duties.

Windows users, please bear with me this week while I discuss a Mac-only technology.

Whether you run a complex Web or print production workflow, or you're a professional photographer who needs to manage 1,000-image shoots, or you're a hobbyist photographer drowning in media, workflow automation can be an essential concern for achieving your end goal -- whether it be a Web site, magazine, or simple high-quality print. Digital photography workflow and workflow automation will be a subject that we will return to repeatedly in this column, but this week we're looking at the digital photography applications of the AppleScript language that's built into the Mac OS and, specifically, the image processing routines that are built into OS X 10.3.

AppleScript was introduced with version 7 of the OS, way back in the early '90s, and Apple wisely migrated the technology to OS X. AppleScript is a scripting language with all of the elements and structures that you would expect of a modern programming language. There's nothing particularly special about AppleScript as a programming language -- in fact, there are a lot of things about AppleScript that are really annoying. What makes AppleScript so useful and powerful are Apple Events -- messages and commands that can be sent from application to application, and which you can control through the use of AppleScript.

An application must have Apple Events support built-in before you can control it with Applescript, but these days almost all major graphics and design applications are scriptable, as are the Macintosh OS and Finder.

AppleScript Basics
A quick summary for those of you who've never fiddled with AppleScript before: AppleScript is part of the standard OS installation and so is available on any Mac. In your Applications > AppleScript folder you'll find a copy of ScriptEditor, a simple application for writing and compiling scripts.

Along with the development of AppleScript, Apple created the Open Scripting Architecture (OSA), an open standard that allows other vendors to create languages that can control and respond to Apple Events. Script Editor lets you write and compile scripts for any OSA-compliant language. So, for example, if you'd rather create your automation scripts using JavaScript, you can install a special OSA version of JavaScript. We'll look more at AppleScript alternatives (which can be ideal for mixed Mac/Windows environments) in a future column.

In addition to saving simple scripts that can be run from a script editing application like ScriptEditor, AppleScript allows you to create standalone, double-clickable applications, droplet applications, or scripts that can be attached to folders or other applications.

The AppleScript language itself is somewhat similar to Apple's old HyperTalk language (the native language of HyperCard) and follows a similar English-like syntax. This is both a blessing and a hindrance. Its English-like feel is less intimidating to beginning scripters, but the vagaries of English grammar -- as well as the existence of so many synonymous terms -- means it can be difficult to remember the precise AppleScript syntax that you need for a particular command.

http://www.creativepro.com/story/feature/22342.html