Travel Doesn't Stop with the First Gray Hair
HomeContact MeTravel TipsGear TipsPhoto TipsStoriesBlogPhotos and Videos
Cameras and Lenses
Photo Software
Camera Supports
Dynamic Range
Lenses on Digital
Macrophotography
Photoshop Automation
Photo Travel
Winter Photo-Travel
Zone System
D7000

Photoshop Automation

Digital photography, like something else I've forgotten the details of, is one percent inspiration and ninety-nine percent perspiration.  The fun part is going to an exotic place and taking a picture like the one above.  The sweaty part is surely the grunt work that has to be done to convert what the camera or scanner captures into something you can print or display online.  Most digital photographers have a system for getting images prepared, and the process of making it happen is called a "work flow".  While you can certainly construct your own workflow by selecting steps from one or more imaging programs and performing them in sequence, most people will want to simplify their task by introducing some automation.  Photoshop, fortunately, gives you a variety of tools for that purpose, and there are third-party extensions and aids available as well.

Let's start with the basics.  There are five different kinds of automation available with Photoshop:
  1. Filters/Plugins.  A "plugin" is a class of application written to interwork with Photoshop to extend its capabilities.  Some plugins are used to create or read special file formats, for example, but the most commonly used plugins are the "Filters".  These are packages that perform specific tasks on images.  You access them from the "Filters" menu item of Photoshop, and a bunch of them come included with the package.  Most of Adobe's supplied filters are kind of "atomic", meaning that they do a single specific thing like Gaussian Blur or Unsharp Mask.  The help file and virtually every book on Photoshop will document at least some of the filters, and it's probably smart to take the time to know them at least to the point where you'd recognize a possible application for one.  You can write your own plugins/filters using Photoshop's software development kit (SDK) if you're so inclined, but that's really a professional developer task and not one for the average photo-junkie.  The SDK isn't free, either; you pay a yearly fee to get it.  An easier but more restrictive way is to use the Filter Factory plugin that's provided with Photoshop.
  2. Actions.  These are essentially "macros" of the type you may be familiar with from Microsoft Office.  Actions are usually created by either recording a series of steps you've developed yourself, or by purchasing them from a third party.  Unlike filters, actions are sequenced executions of other Photoshop tools or steps, so they don't add capabilities so much as simplify how things are done.  You can execute actions individually from the Action Palette or you can use Photoshop's "Automate>Batch" sequence to run an action on a bunch of files/images.
  3. Droplets.  This is a really non-descriptive name for a sort-of-neat capability.  You think of "paint" or color when you see the term, but what it really means is "drop" as in "drag-and-drop".  In brief, a "droplet" is an icon that represents an action you've already bought or created.  This icon is like a program in that it isn't a part of Photoshop, but something that looks like an independent program on your desktop. You can drag an image to it to execute the action.  If Photoshop is running, the process just executes the action.  If Photoshop isn't running, the drag-and-drop executes Photoshop and then runs the action.  You can drag a file or a folder, and in the latter case the action is executed on the entire folder.  In a technical sense, a droplet is a drag-and-drop wrapper around a combination of Photoshop and an action.
  4. Built-in automations.  Photoshop has a number of built-in automations that are very helpful but also very specialized.  You can create a web gallery of images, for example.  Dandy tools, but there aren't many of them.
  5. Scripts.  Scripting is an optional add-on (free as of this moment) to Photoshop 7 that allows you to create little application programs (scripts) using a variety of languages, including JavaScript and Visual Basic.  Photoshop CS includes scripting capabilities right out of the box.  Scripting is an extraordinarily powerful tool, but it also requires some understanding of the scripting language to be used, so it's again somewhat of a programming function.  However, scripting languages are a lot easier to use than the SDK's application program interface (API).

For users, it's clear that the flexibility associated with automation is really confined to two of these choices-actions and scripts.  Filters and the built-in automations are static tools that you use or not; you can't change their function.  Droplets are a way to mechanize actions.  It's actions and scripts that offer your choices for automating tasks.

What's good about actions is that it's easy to use them.  You create an action by carefully planning out a series of steps you want to automate, then opening the Actions Palette, selecting "New Action", naming the action, and hitting the "record" button.  When you finish your steps, you stop the recording and you've got an action.  Simple.

What's bad about actions is that they do exactly what you record, and you can't record human judgment (you can make an action stop for manual handling, though).  There are no decision-making steps possible in actions, and very limited opportunity to introduce manual operations in the middle of one.  A good example of this limitation is a simple thing like creating a uniform-sized JPG for web use.  You want to put a bunch of pictures on a web page, and you want each to take up a similar space (total area) versus the same horizontal space.  That means that you have to size the image based on the width dimension for landscape orientation and on the vertical for portrait.  How to build an action do to that?  You can't.  Instead you have to have a "Landscape2JPG" and "Portrait2JPG" action, separate your pictures by orientation, and run the actions on the right group.  Actions thus simplify workflow by reducing the number of repetitive steps, but you don't usually get down to one step.

Now, I don't know whether I have a unique failing here, but if I have three or four things that I have to do in just the right sequence, with just the right file setup before and after, there's a darn good chance I'm going to mess up.  Because we're dealing with images that have a lot of work in them, the risk of messing up means taking time to back images up.  Backing images up means you now have two copies (at least) to get out of synchronization if you make further adjustments to one…you get the picture.  Add to this mix the fact that you may be dealing with literally hundreds of images (in Africa I took 5426 pictures and processed perhaps 500 for later use on a website, printing, etc.), and you've got a formula for an interminable and agonizing process.  It makes photography more work than fun.

Enter scripts.  Since a script is essentially a little Photoshop-linked application program it can interrogate things like the orientation of the image, and perform steps conditionally.  Scripts can distinguish between portrait, landscape, and even odd-cropped sizes.  They can create layers, move and size text, fill in file information, and do a bunch of really tedious things for you-if you can write one.  It's possible to buy scripts, like actions and filters, but it's harder to find them and you probably won't get exactly what you want.  So, photo-type, you've got to decide if you're up to programming in one of the scripting languages that Photoshop supports, and if so you've got an opportunity to do some really powerful stuff.

Hang on to your hats here, because I have to get a little technical.  On the other hand, if you don't understand this level of discussion, you'll probably do something truly awful if you try to write a script.  Use this as a test, folks.  If you can't read this then don't try scripting!

Scripts are based on object-oriented programming.  The application (Photoshop, in this case) is treated as an "object" in the programming language that you elect to use.  In the Photoshop object there are variables and functions and methods and all that good programming stuff, and you can call on all of these to bend Photoshop to your will.  The capabilities of scripting in Photoshop are still somewhat limited; there are things that you can't really do well or at all, but in general the capabilities of scripting will be more limited by the language you select and your own skill than by the object properties of Photoshop and the scripting module that you get from Adobe.  Remember, Photoshop CS comes with scripting support built in.

For things that scripts can't do alone, scripts can be used to invoke actions.  In fact, there are many really useful workflow automation tasks that really benefit from the combination.  The nice thing about combining scripts and actions is that actions have the full range of Photoshop tool options available to them, and actions can be changed relatively easily.  For example, you could write a script to perform a couple standard start-the-image-editing-flow processes by invoking an action, and then edit the action if you find your process changes over time.

Some hints with script development are in order:
  • You can automate really destructive things with scripts.  "Throw text randomly onto pretty pictures and then flatten image and save" may not be what you had in mind, but a few careless errors and it's what you might end up with.  Moral: test scripts on limited image groups that you've copied first.  A corollary to this is "never write a script that works on a fixed directory", because you'll forget to populate that directory with test-only data and end up messing up a bunch of production images.
  • The best scripts let you select the input directory and the directory to which the output will be written.  Until you're confident, don't write into the source directory, and remember that if you do decide to write back into your source directory and at the same time change file names, your script may run again on your output file!  For example, if you write a script to process every file in a directory and convert it to JPG format, your script may run first on the Photoshop file and convert it to JPG, and then on the JPG file converting it again!
  • Remember that working on a directory full of files works on just that-all the files in the directory.  Be sure that they're all compatible with Photoshop and that you really want to run the script on all of them.  If you want only specific file types, test for the types you want in the script.
  • Include a very detailed comment section at the start of each script that lays out what it does, what conditions should exist before the script is run (all the files should be in "x" directory), and what the end result will be.  In addition, comment each step carefully.  Otherwise, you'll forget what's supposed to happen, and that's the first step in making something bad happen.
  • Work up to complex scripts slowly, by making little scripts that do individual steps and working the bugs out of them first, then combining functioning scripts into something bigger and more complex.
  • Stay with a single scripting language unless you're really a programmer or have some sort of internal masochistic streak.  You'll tend to get the details of your several language choices confused otherwise.
  • Store all your scripts in a single directory, both source and (if available) executable files.  Otherwise you'll always be looking for where you put one, and that may not be an easy task.  Keeping your scripts centralized also insures that you won't accidentally copy a purchased script or program over one you've written.  Make sure that the directory that contains the scripts isn't a directory you're going to run the scripts on, too!

What's your best option for a scripting language?  Most non-programmers will find JavaScript the right answer.  There are plenty of books on it, and the Photoshop scripting package that you'll need to download includes interpreter logic for JavaScript so you don't need to buy additional software.  But JavaScript isn't a true programming language, and JavaScript applications have to be started from within Photoshop itself.  Visual Basic gives you the most power and flexibility, but the way that Photoshop supports VB has changed with the new CS2 version.  In the "old" days, you could write a Photoshop "program" using Visual Basic 6 or Visual Studio .NET.  This worked with Photoshop 7 and Photoshop CS, but it apparently doesn't work with CS2 and later.  We were unable to get any of the older programs to compile with CS2 (we didn't even try with CS3).  Instead CS2 supports Visual Basic Scripts which are entered into a text editor and "run" using Internet Explorer.  We don't like the new process as well because you don't get smart checking of syntax and smart insertion of variables.

The safest and easiest scripts are JavaScripts that are run as part of actions.  We now have a couple of smart resizing scripts that size an image based on its maximum dimension whether it's portrait or landscape, which is highly useful.  If you stick such a script into an Action, you can create an action that sizes images to a maximum dimension to keep the screen from scrolling when viewed, and avoid the risk of opening files and directories in the script because each script "pass" runs only when the Action invokes it.  That way you control your file/directory loctions the way you did in actions.

But it's not always beer and roses, as they say.  One of my favorite computer cartoons, a relic of an earlier age, applies to scripting.  In it, a guy comes home from the office, tosses his briefcase on the sofa, and announces "I made a mistake today that would have taken a hundred mathematicians a thousand years to make!"  Automation produces results faster, but not necessarily the right ones.  Remember that when you're automating things with any of Photoshop's facilities, and you'll be a lot happier.


HomeContact MeTravel TipsGear TipsPhoto TipsStoriesBlogPhotos and Videos