Anyone who’s ever used Photoshop’s actions in any serious way will have hit a wall at some point. That wall has been the inability to process different kinds of images in different ways — based on orientation, resolution, or something else. Photoshop CC alleviates the pain by allowing you to run separate actions on different kinds of images. Finally. Let’s take a deeper look.
What can we do with this?
While you can run into many issues when processing images through actions, one real-world example centers around processing a landscape image in a different way to a portrait image. If you need all your images to fit within a certain maximum dimension, then you’ll need to do exactly this. In this article, we’ll see how to convert a mixed collection of images to JPEG, centered within a 1000x1000px canvas, surrounded by a black border.
Different actions, based on...
Photoshop’s solution allows you to insert a new Conditional step into an existing Action, which then branches out into two other actions depending on some property of the image. You can branch based on image orientation, color mode, color depth, the presence of layers, alpha channels or selections, and on several properties of layers.
To make our example work, then, we need to create two different actions — one to process portrait images, and another to process landscape images. We then need to create a parent action which directs the flow to the appropriate child action for processing. (It’s worth noting that you can also detect square images, but we’ll assume that our source images aren’t square.)
Before you continue, you’ll need a collection of images in different orientations.
A few original images to work with.
We’ll begin by recording the action which processes landscape images. In the Actions panel, press the folder button at the bottom of the panel to create a New Set to hold these actions. I’ve created one called “macProVideo”.
Next, open up one of your landscape images so you have something to work with. Now, we’ll start recording: press the New Action button (the standard Adobe-style document-with-upturned-corner icon) to create a new Action, and call it “1000px square from landscape”.
You’re live now, so try not to make any mistakes — everything is being recorded, including undo and stepping backwards. Choose Image > Image Size, then set width to 1000 pixels and press OK.
Image size first.
Choose Image > Canvas Size, then set height to 1000 and units to pixels. Set Canvas extension color to Black from the menu, then press OK.
Canvas size second.
Choose File > Save for Web, choose the JPEG High preset as a starting point, then increase the quality to 70% if you’d prefer slightly higher quality images, or lower if you’re not feeling fussy. Press Save, then create a new folder called “output” on the Desktop, and save your image in there.
Saving to a new folder with good quality.
You’re still live and don’t want to damage your original file, so choose File > Close and the press Don’t Save.
Remember not to save.
Finally, stop recording by pressing the square button at the bottom left of the Actions panel. If you made any mistakes or repeated any actions, you can drag steps in your action to the trash icon now.
Right-clicking doesn’t work here (yet?) so we’ll have to go old-school. Select the name of your action, then go to the Actions panel submenu and choose Duplicate. (Pro tip: The super-secret menu-free way is to drag your action to the New icon. Works with layers, channels and paths too.)
Duplicating tricks can be fun.
You’ll want to rename it, so double-click the name of the copy, then change the words “landscape copy” to “portrait”. Next, let’s fix this action so that it does the right thing for a portrait-oriented image.
And ready to change the new copy.
Open one of your portrait images in Photoshop. It’s easy to re-record a step in an action; all you need to do is double-click it. While this action would have been simple to redo from scratch, more complex actions are definitely easier to change this way.
Double-click the Image Size step in your new portrait action, then change the height to 1000 pixels and press OK.
Image size first.
Next, double-click the Canvas Size step, hold the Option key to turn the Cancel button into a Reset button, then press it. Change the width to 1000 and the units to pixels. Press OK.
Canvas size second.
We don’t need to change the rest of the action, so close without saving.
To make the magic happen, we’ll need to place a new Conditional into a new Action. In the Actions panel, press the New icon to create another new action, and call it “1000px square”. Press Record, but immediately stop recording. With the new action still selected, choose Insert Conditional from the Action panel submenu.
Let’s get that Conditional in there.
In the resulting dialog, choose “Document is Landscape” from the If Current menu, then choose your “landscape” under “Then Play Action” and “portrait” under “Else Play Action” in turn.
The “Then Play Action item is, of course, your “landscape” action.
None of our actions include any Open commands, so we’ll set off the action using batch processing instead. Make sure your “1000px square” action is selected in the Actions panel, then choose File > Automate > Batch. In the Source section, choose Folder if necessary, then press the Choose button and locate the folder containing your source files. For safety, tick the two options that start with “Suppress”.
Something like this.
Destination can be safely left as “none” because we used Save for Web during recording. Save for Web automatically assigns names based on the existing source files. However, if you’re not trying to save for the web, you could omit those steps from the recorded actions and use the Save and Close option in the Destination section.
Finally, press OK.
Each image will be opened, processed nearly instantly and saved in the destination “output” folder on the desktop. The original files remain untouched, while the newly created files have black borders around the outside. If you’ve never seen this trick before, it’s like dark magic.
And you’re done!
If you regularly process images in Photoshop, you really should be using actions as much as possible. The difference now is that you can deal with many different kinds of images effectively, rather than having to manually process or sort your images beforehand. If you come up with any interesting recipes, please share them in the comments. Good luck!