Writing actions for batch-processing raw images is relatively simple. You don't need to worry about making sure that the action can operate on files that already have layers or alpha channels, or that are in a color space other than RGB. You're always dealing with a known quantity.
Bear in mind that if your actions call other actions, the other actions must be loaded in Photoshop's Actions palette, or the calling action will fail when it can't find the action being called. An easy way to handle this is to make sure that any actions on which other actions are dependent are saved in the same set as the actions that depend on them.
I'll start out with simple examples and proceed to more complex ones.
Simple ActionSave as JPEG
I'll start with a very simple action that opens a raw image at its native resolution and saves it as a maximum-quality JPEG in the sRGB color space.
Creating an action and action set
Start out by creating a new action set called "Batch Processing" in which to save the actions you'll create in the rest of this section. So the first step is to create a new action set, which you do by opening the Actions palette and clicking the folder ("Create new set") icon and then entering the appropriate name in the ensuing dialog box and clicking OK to dismiss it. The new set then appears in the Actions palettesee Figure 9-2.
Figure 9-2. Creating an action set
To create a new action set, click the "Create new set" icon, enter a name, then click OK. The new set appears in the Actions palette.
Creating a new action
Before creating the action, select a raw image in Bridge that has already had custom Camera Raw settings applied. That way, once you've created the action, you can start recording immediately without recording any extraneous steps, such as selecting a file, and you can correctly record the Camera Raw Selected Image setting.
Click the "Create new action" icon in the Actions palette, enter the name"Save as JPEG"in the ensuing dialog box, and then click Record to dismiss the dialog and start recording the action.
Recording the Open step
The first step is to open the image in Camera Raw, so that you can include the correct Camera Raw settings in the action. When you use the action in Batch, the Camera Raw dialog box won't appear, so it's essential to get these settings right when you record this step. Open the image by pressing Command-O (you must open the image in Camera Raw hosted by Photoshop), and the Camera Raw dialog box appearssee Figure 9-3.
Figure 9-3. Recording the Open step
When you record an Open step, it's critical to make sure that the Settings menu is set to Image Settings and the workflow settings are set the way you want them for the batch operation.
You need to record several key settings for this action in the Camera Raw dialog box.
Then click OK to open the image. (If the Profile Mismatch warning appears, click OK to dismiss it. This doesn't get recorded in the action, and you'll suppress the warning when you use the action in Batch.) The image opens, and the Open step appears on the Actions palette.
Recording the Save step
To record the Save step, choose Save As from the File menu, or press Command-Shift-S. The Save As dialog box appears. The filename and the destination for saving that you enter here has no impact on the batch processI always enter an obviously silly name such as "foo.jpg" (I'm too lazy to type "throwmeaway.jpg") and choose the Desktop as my destination, to simplify cleanup. See Figure 9-4.
Figure 9-4. Recording the Save step
When you apply the action in a batch operation, the filename and destination will be overridden, but the format options will be applied.
Make sure that the format is set to JPEG, and incorporate any other settings in this dialog box that you want to include in the action. In this case, I'll leave all the options uncheckedany RGB file that I create without an embedded profile can safely be assumed to be sRGB, and I don't care about icons or thumbnailsbut if you want any of these options included in your batch-processed files, check them now.
Click Save to proceed to the JPEG Options dialog box, set the desired quality, set the Format Options to Baseline for maximum compatibility with JPEG-reading software, and then click OK. The File is saved on the Desktop as "foo.jpg," and the Save step appears in the Actions palette. Then close the image so that the Close step appears in the Actions palette.
Stop and Save
Click the Stop button in the Actions palette to stop recording. Photoshop doesn't allow you to save individual actions, only action sets; so if you want to save an action as soon as you've written it, you need to select the action set that contains it in the Actions palette and then choose Save Actions from the Actions palette menusee Figure 9-5.
Figure 9-5. Saving the action set
Note that until you save actions explicitly using the Save Actions command, they exist only in Photoshop's Preferences, and Photoshop's Preferences only get updated when you quit the application "normally" by using the Quit command. If Photoshop crashes, or you suffer a power outage, any unsaved actions will be lost. A simple action like this one probably wouldn't have me running to the Save Actions command, but if you make any actions that are even slightly complex, it's a very good idea to save them before doing anything else. You can save actions anywhere, but if you want them to appear automatically in the Actions palette even after deleting Photoshop's preferences, save them in the Adobe Photoshop CS2/Presets/Photoshop Actions folder.
When you expand the steps in the Actions palette by clicking the triangles beside those that have them, you can see exactly what has been recorded for each stepsee Figure 9-6. When you use this action in Batch with the appropriate overrides selected (see "Batch Processing Rules," earlier in this chapter) the filenames and folder locations you recorded will be overridden by the settings in the Batch dialog box, and all the other settings you've recorded herethe Camera Raw workflow settings and the JPEG Save Optionswill be honored.
Figure 9-6. Save as JPEG action
You can create variants of this action by recording different Open or Save steps. For example, you can create larger JPEGs by changing the Size setting in the Camera Raw dialog box to one of the larger sizes, and you can embed thumbnails or create lower-quality JPEGs by making those settings in the Save As and JPEG Options dialog boxes, respectively. To save in a different format, with different options, just choose the desired format and options when you record the Save step.
Complex ActionSave for Edit
The following example is a more complex action that produces 16-bit/channel TIFFs with sharpening applied and adjustment layers set up ready for final editing in Photoshop. It's designed for use on "hero" images that merit individual manual edits in Photoshop. It doesn't actually do any of the editing, because the required edits will almost certainly be different for each image in a batch. Instead, it simply does a lot of the repetitive grunt work involved in setting up an image for editing, so that when you open the image, all the necessary adjustment layers are already there, waiting for you to tweak them.
Creating a new action
Record this action in the same set as the previous one, since it's also designed for raw processing. As before, select a raw image that has had custom Camera Raw settings applied before you start recording the new action. Then click the "Create new action" icon in the Actions palette, enter the name "Save for Edit" in the New Action dialog box, and then click Record to start recording.
Recording the Open step
As before, start by launching Camera Raw by double-clicking the selected image. In the Camera Raw dialog box, again make sure that Settings is set to Selected Image. This time, though, you'll make some different workflow settings.
Then click OK to open the image. The image opens, and the Open step appears on the Actions palette.
Adding the edits
This action adds four different editing layers (actually, three layers and one layer set) to the image before saving and closing. First, add sharpening layers using your sharpening tool of choice (mine is PhotoKit Sharpener from Pixel Genius LLC). Then add a Levels adjustment layer, a Curves adjustment layer, and a Hue/Saturation adjustment layer, as follows.
When you open the resulting images in Photoshop, you can start editing immediately by double-clicking the adjustment icon in each adjustment layer without having to do the work of creating them first. If you don't need all the adjustment layers, you can easily throw the unused ones away. All the edits will be performed in 16-bit/channel mode for the best quality.
Recording the Save step
Record the Save by choosing Save As from the File menu. Again, name the file "foo" and save it on the Desktop for easy disposal. This time, choose TIFF as the format, make sure that the Layers and Embed Color Profile checkboxes are checked (creating untagged ProPhoto RGB files is a Very Bad Idea). Then click Save to advance to the Tiff Options dialog box.
In the TIFF Options dialog box, choose ZIP for both Image Compression and Layer Compression, and then click OK to complete the savesee Figure 9-8.
Figure 9-8. Save as TIFF
Finally, close the image (so that the batch operation will do so too), and click the Stop button in the Actions palette to stop recording. Figure 9-9 shows the resulting action in the Actions palette with all the steps expanded.
Figure 9-9. Save for Edit action
As with the earlier, simpler action, when you use this action in a batch process with the necessary overrides applied in the Batch dialog box, the filenames and locations will be overridden by the Batch settings, while everything else in the Open and Save steps will be honored.