www.dpreview.com
www.dpreview.com

Automating Photoshop

Ellen Anon | Software Techniques | Published Jan 23, 2012

What if I told you that by the end of this article I could drastically boost your Photoshop productivity? Interested? That's actually not an exaggeration if you've never taken advantage of Photoshop's actions and batch processing tools. If you find yourself repeatedly performing the same (often mindless) tasks in Photoshop one step at a time, I'm going to show you a better way to work.

Actions are essentially a way to have Photoshop perform a series of predetermined steps on an image. You create them by first manually performing steps for Photoshop to record. But don't worry, Photoshop isn’t timing you when you record an action. No matter how long you take to perform the steps, once the action is created Photoshop will execute it as quickly as possible, which will always be faster than we mere humans could do it. Most Photoshop commands can be included as part of an action, and I'll show you how you can incorporate those that cannot.  

We'll explore how to:

In this article I'll be using Photoshop CS5. While Photoshop Elements cannot be used to create actions, it can import and run actions created in CS5.

Creating a basic action

Actions live in the Actions panel, available if you go to Window>Actions. Without creating a single action of your own you’ll see the list of default actions that ship with Photoshop. It's important to note that an action must reside in a folder, called an action set. You can name both the Action Set as well as the individual actions. Because Action Sets are the primary means of sorting and finding your actions, I recommend giving them descriptive names that relate to the actions contained within them.

A collection of Photoshop's pre-built
actions can be found in the Default
Actions folder of the Actions panel.
More action sets are available
via the panel's fly-out menu. Click
on one to add its contents to the
Actions panel.

Let's begin by creating a new action set to store our custom actions. Click the folder icon at the bottom of the Actions panel (shown below). A dialog then appears in which you name this new set. In the examples below I typed 'Ellen’s Actions'. This set is where I will store the actions I'll be demonstrating in this article. As you start to create additional actions on your own, however, I recommend that you create several distinct sets that are geared towards specific techniques such as resizing, editing or prepping for output and name them accordingly.

The most common action tasks can be performed by clicking on icons along the bottom of the Actions panel. When you click the New Set icon... ...you're prompted to name the set. I recommend a descriptive name that gives a hint as to the actions contained within it.

In this action we're going to add a copyright watermark to an image. Open an image in Photoshop (the simplest, though not the only way to begin) and then click the New Action icon (shown above). Because we're going to create a white watermark to use on images that are 1280 pixels wide, I name the action accordingly (shown below). 

I've given the action a descriptive name and chosen to house it inside the 'Ellen's Actions' set.

Notice that you can also assign a Fn key to invoke the action, as well as give it a color label.

Press the Record button. To create the watermark perform these steps:

1. Select the Text tool (T) and choose a font, size and color from the Options bar. 2. Create the © symbol by pressing Opt+G on a Mac or hold the Alt key and press 0169 on a PC. Then type your name.
3. Select the Move tool (V) and position the text. 4. Reduce the opacity of the text layer in the Layers Panel as desired.

5. Go to Layer>Flatten Image. 
6. Press the Stop recording icon.
7. Close your image (without saving it).

That's it. You’ve created a watermark action. To test it, open the same image you began with, select your newly created action from the Actions panel and click the Play button.

Before we go any further, you should know that by default the actions sets you create are stored in Photoshop's preferences. Should those get reset or corrupted, you've lost your actions. Fortunately you can save action sets to a more easily accesible location on your hard drive, which I strongly recommend.

With an action set highlighted, clicking on
the panel's fly-out menu lets you save the
it and all of the actions it contains.
Action sets are saved with the '.atn'
extention and can be stored on any shared
drive within your network.

Doing so allows you to export them to another computer, share them with others (including Elements users) and easily bring them into a newer version of Photoshop should you upgrade.

Click here to continue reading our Automating Photoshop article...

Creating an action with a modal control

Actions register not just the dialog boxes you bring up while recording, but the exact settings you assign to them as well. There may be times, however, when you'll want to create an action for tasks that require you to change these values on a per-image basis. Photoshop allows you to enable what's called a modal control to pause the action at the point where you need to enter your alternative settings.

Modal controls can also be used with tools such as Crop or Transform that require you to commit to a task before it is applied. With a modal control enabled, the action will pause so you can alter the adjustment you performed when recording the action. And as soon as you commit to your new adjustment (usually by clicking OK or pressing Enter/Return) the action resumes running. Confused? Don't worry. This is much easier to demonstrate than explain, as you'll see in the example below.

Here’s an action to crop an image in a way that will extend the canvas, automatically filling in the empty areas using Content-Aware Fill. First, open an image and click the New Action button as described earlier. Begin recording and do the following:

1. Double click on the background layer to unlock it. Click OK in the dialog that appears. 2. Choose the crop tool and draw a crop. Click at least one edge of the crop and extend it beyond the edge of the image. Press Return/Enter to apply the crop.
3. Hold down the Cmd/Ctrl key and click the image icon in the layers panel. This selects all of the image pixels on the layer. 4. Go to Select>Inverse to select the transparent pixels. Then go to Select>Modify>Expand and enter a value of 3. Click OK.
5. Go to Edit>Fill>Use Content Aware and click OK. 6. Go to Select>Deselect to remove the marching ants and press the Stop button to end the recording.

The problem with this action is that, when applied to other images, the crop dimensions will always be identical to those when we created the action. To gain the ability to customize the crop for different images we need to add a modal control. And it couldn't be simpler to do.

Go to the Actions panel and open the disclosure triangle to display all the steps in the action. Click in the empty box next to the Crop step. A grey icon appears (highlighted here in red), which indicates the action will pause at that step.

The next time you run this action it will pause after the crop is drawn, allowing you to adjust it however you wish. As soon as you commit to the crop, the action automatically resumes, performing the rest of the steps. Pretty slick!

After trying out this action on your own images you'll soon realize that Content Aware Fill is not perfect. Although it attempts to 'intelligently' choose areas from which to sample - and will vary its sampling area on successive attempts - the more detailed the background you're expanding and/or the larger the expansion you specify, the greater the chance the image will need some extra attention afterwards. In my image the left side of the image showed obvious defects. I needed to manually use the healing and clone tools to get the result you see below.

Here is the original image. After the action is run, the image canvas is extended slightly along the left side and bottom of the frame.

Click here to continue reading our Automating Photoshop article...

Creating an action with a stop

Another means by which to pause an action is to insert a stop command. Unlike modal controls, stops are meant to allow you to perform tasks that can’t be recorded in an action, such as painting with the brush tools. When defining a stop, you can create a message of up to 254 characters to remind you, or anyone else running the action, of the task to be performed while the action is halted. Once the task is completed the action can be resumed from exactly where it left off.

I created this next action to help separate a subject from a distracting background. It includes a blur layer with a layer mask, a blending mode change and a Saturation and Vibrance adjustment layer with its own layer mask. I've included a stop within the action in order to create a customized layer mask before continuing with the rest of the automated steps.

To begin, open an image where you’d like the subject to stand out more prominently from the background. Then create a new action as described earlier and name it 'Distracting Backgrounds'. Here's what to do as Photoshop records your steps.

1. Duplicate the background layer. 2. Choose Filter>Blur>Gaussian Blur and set a blur. Often you want to retain a strong sense of the background but with less detail.
3. Add a layer mask to the background copy layer. 4. Use the Action panel's fly-out menu and click Insert Stop.
5. Type a message reminding you to set the foreground color swatch to black, choose the brush tool and paint to remove the blur from the subject. The Allow Continue box should remain unchecked. 6. Perform the tasks described in Step 5, but keep in mind that Photoshop cannot record brush strokes. After painting on a layer mask I enable the red rubylith view (\) which displays the mask itself so I can see if I've missed any areas and make adjustments as needed.
7. Change the blending mode to Multiply. 8. Add a Vibrance adjustment layer and reduce the Vibrance slider as desired. (You may want to add a modal control at this step so you can modify the amount of desaturation.)
9. Insert a stop. Enter a note reminding you to copy the layer mask from the Background copy layer onto the Vibrance layer. You can do this by holding the Option/Alt key while clicking and draging the background copy layer mask over the exisitng Vibrance layer mask. 10. A dialog will appear asking you to confirm the mask replacement. Click yes. End the recording.

When you run the action and it arrives at the stop command, the message you typed - stating what needs to be done - will appear.

When presented with the first dialog box we created, click Stop to pause the action and take the necessary steps. Then press the Play icon on the Actions panel to resume running the action.

Notice that in this particular action I inserted a second stop at the end. Obviously you won't need to resume running the action after completing the described tasks. Below you can compare the original image with the one after the action was performed.

The background in the original image is distracting. This action darkened and slightly blurred the background, making the subject more prominent.

Fine-tuning your actions

You can make actions as simple or as complex as they need to be. None of us are perfect, however, and its not uncommon to have to go back and adjust some portion of an action to get the results you were expecting. Luckily, actions are easy to edit.

If you need to add additional steps to an action, make sure the action step from where you wish to resume recording is highlighted, then click the fly-out menu and select Record Again. If you've inadvertently created a step you can select it and click the Delete icon. You can press Cmd/Ctrl to select multiple steps and delete them simultaneously.

Prepping images for editing

Another, perhaps less obvious use of actions is to automate the preparation work required for your creative adjustments. Look at the screenshot below. It's the result of an action I created by pressing the record button as I did the following:

I can run this action with one click and be ready to start painting on the adjustment layers.

You can us an action to do all of the prep work and quickly set about making your adjustments.

If you perform edits that commonly involve the same setup of layers, masks, or other prep work, consider creating an action to speed up the process. You might be surprised at just how much time you save over the course of editing even a few images!

Click here to continue reading our Automating Photoshop article...

Batch processing

So far, we've been applying actions to a single image. Actions acheive the greatest time savings, however, when they are applied to multiple images in a single step. You can do just that using Photoshop's Batch feature.

The Batch dialog is very flexible, but far from intutive, which prevents many from using it successfully.

You call up the Batch dialog (shown above) by going to File>Automate>Batch. To specify an action to apply, you must first select the set in which it is contained. The Source drop down menu is where you'll specify which images are to be processed by the action. 

While you can batch process files that are already open, a more efficient way of working is to select the Folder option and then click the Choose button to navigate to the appropriate directory on your hard drive (shown at left).

Checking the Include All Subfolders box does exactly what its name  implies. It will process images residing any number of levels beneath your source folder.

If your action contains an Open command, you must check the Override Action 'Open' Commands box. If you don’t, the action will process the same image you used to create the action, instead of the images you just specified in the Source option.

If, on the other hand, your action doesn’t contain an Open command, leave this option unchecked.

The Suppress File Open Options Dialogs option should be used with care if you're including raw files. Checking this box will prevent you from adjusting any ACR settings. The ACR dialog will not even open, and instead, the raw file will be processed honoring pre-existing custom settings on a per image basis. If you've never adjusted the raw file before, ACR's default settings will be used to render the image.

I generally recommend you select the Suppress Color Profile Warnings so that the action won’t stop for missing profiles or profile mismatches.

The Destination section of the dialog is where you determine how and where Photoshop will save your processed files.

Photoshop gives you three destination options. Choosing 'None' leaves the file open onscreen (unless your action contains Save and Close steps). The second option, 'Save and Close', commands Photoshop to overwite the original file. The option I use most often, however, is 'Folder', in which I designate a specific location to store the processed files.

The Override Action Save As Commands box (shown below) is crucial to the success of your batch process. If you have a Save As command within the action, check this box if want your new files saved to the folder you specify in the Batch dialog rather than the one you used when you recorded the action.

Checking this override box will also ensure that these newly created images are named according to the file naming options (shown below) you specify in the Batch dialog rather than the name you used in the Save As step while recording the action.

When you select 'Folder' as the destination choice you can specify file names for your images. You can enter custom text in each of the text fields and/or choose from a list of built-in options.

You can populate filenames with a list of preset options (shown at left) or you can type in custom text. The 1-4 digit serial number options in the drop-down menu are an easy way to create sequentially-numbered files.You can even select the starting number in the sequence.

I suggest leaving the Errors drop down menu set to Stop for Errors so that you know right away if there’s a problem.

When you’ve configured the Batch dialog to your liking, click OK and Photoshop will immediately begin processing all the files you’ve specified. Batch processing can be a huge timesaver. In fact, the first few times you use it, you may want to sit back and watch your screen as Photoshop opens and processes your images at blinding speed!

Creating a droplet

You can make batch processing even more convenient by creating a Photoshop droplet. A droplet is simply a file that executes a specific action when you drag and drop image files onto it. A droplet can reside on the desktop or any other location on your hard drive as an easy shortcut to perform a specified action. You can drag and drop multiple images or even an entire folder to process all of the images contained within it. If Photoshop is not already running, the droplet automatically launches it for you.

Creating a droplet is very similar to creating a batch process. You invoke the dialog shown below by going to File>Automate>Create Droplet.

The Create Droplet dialog is nearly identical to the Batch dialog except that it begins with a 'Save Droplet In' option where you specify the droplet's name and location where it will reside. You select the same settings and options as in the Batch example.

Note that droplets are ideally suited for completely automated operation. Actions that contain stops or are enabled for modal control are better used in a batch process. And you should always test any action and verify that it performs as expected before linking it to a droplet.

Here is the resulting droplet icon as it appears in the Finder. Dropping files onto it automatically launches Photoshop if it’s not currently running.

Click here to continue reading our Automating Photoshop article...

Using the Image Processor

All of the methods we've discussed, while incredibly flexible, share a specific limitation. They produce just one instance or version of the processed image file. Photoshop's Image Processor is unique in that it can save up to three versions of the original image file, at different sizes in a choice of JPEG, PSD or TIFF formats. From a single image you can optimize output for print, slideshow and web, for example. Image Processor can even include an action to be run on the images. Here's how to use it.

1. Go to File>Script>Image Processor. If you
are working in Adobe Bridge, go to Tools>
Photoshop>Image Processor.
2. Click the Select Folder button to specify the
the images to be processed. Here I've chosen
a folder of images on an external hard drive.

Understanding the dialog's 'Open first image to apply settings' box is crucial if you are processing raw images. Checking this box will open the initial image in ACR so that  you can then adjust image settings to taste. These exact values will be used on all of the remaining raw images. Leave this box unchecked and instead of presenting the ACR dialog, the Image Processor will honor all existing ACR settings for each image or use the default ACR settings if no custom settings exist. If you've previously made individual adjustments to all of your selected raw files, this option makes the most sense.

3. If you checked the 'Open first image to
apply settings' box, make the desired edits
to the image that opens in ACR. These same
values will be applied to all remaining images.
4. Specify a location to save the processed
images. If you choose the 'Save in Same
Location' option, a sub-folder for each file
format (shown here) is automatically created.

Image Processor's Resize to Fit option is perhaps the tool's most useful feature. That's because in the boxes for pixel width and height (shown below) you specify maximum, not absolute dimensions. Image Processor will then resize the image's longest dimension while maintaining its original aspect ratio. The upshot is that you can set one specification that works for both horizontal and vertical images.

5. Set identical pixel dimensions for both width and height. The image's longer dimension will be set to the specified value with the shorter dimension maintaining its proportional value.
6. Select any combination of JPEG, PSD or TIFF files to be generated from the same original image. If your JPEG is destined for the web, you should check the Convert Profile to sRGB box.
7. Select a prerecorded action to run by choosing an action set in the left drop-down menu (expanded here) and then selecting your desired action.

7. You can type in copyright data which will be embedded in the image's metadata. It will not appear onscreen as a watermark.

8. I always recommend selecting the Include ICC profile option.

9. Click the Run button and the Image Processor applies your selected action, creating as many separately-sized versions as you've specified.

Any settings you’ve made in Image Processor can be reused by clicking the Save button near the top of the dialog. This will generate an XML file that you can save to any available hard drive. To recall these settings in the future, simply hit the Load button and navigate to this same XML file.


Ellen Anon is the co-author of Photoshop CS5 for Nature Photographers; A Workshop in a Book (Anon & Anon, Sybex 2010.)