Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Photoshop

  • Print
  • + Share This
Like this article? We recommend

Actions and Scripting

The trick to being really productive and efficient with computer technology is to be lazy. Yes, it’s a paradox, but it’s true; the lazier you are, the more likely you are to find the really efficient ways of doing things so you can get out of work faster and go to the beach.

Photoshop offers four automation features: actions, Automate, Variables, and scripting. Actions live in the Actions panel and let you repeat a series of steps, similar to the macros you may have used in office programs. Photoshop ships with a number of premade actions, and you can easily build your own (we’ll show you how). Automate refers to the built-in tools in the File > Automate submenu such as Batch and Photomerge; we’ve chosen to cover them where they apply. Variables provide a way to create a template image that changes depending on data imported from a spreadsheet or a database; because they’re used primarily in Web design, we don’t cover them in this book. Scripting automates Photoshop from behind the scenes using AppleScript, JavaScript, or Visual Basic. We’ll look at aspects of actions and scripting that we haven’t yet covered.

Actions

In Chapter 5, we discussed some of the basics of building actions—particularly actions that help in the processing of raw files. But Photoshop also comes with a number of premade actions that are not only useful but educational, because you can look at them to see how they produce their magic. (You can load additional sets of actions by selecting Load Actions from the Actions panel menu, or by choosing the presets that appear at the bottom the panel menu.)

The key is that you can make an action only for something you can do blindly, with no feedback from the program, and with little or no brain activity. For example, you can’t record an action that says, “If the pixels in the upper left corner of the image are sort of reddish, then do such-and-such.” Photoshop would have to be able to see and respond. No can do.

However, you can easily create an action that runs a particular set of Curves, adds a text layer, adds a layer effect, sharpens the background layer, and so on, because all these things are methodical.

Action Limitations. Before you get too heady with your newfound actions power, you should know that Photoshop doesn’t let you record everything you might want. Although you can record blending modes, opacity, shapes, brush selections, and even pixel selections, you still cannot record brushstrokes (such those made with the Brush, Airbrush, and Clone Stamp tools), zooms, window switching, and scrolls. And there are many features that aren’t necessarily record able but that you can force into an action (see “Editing Actions,” later in this chapter). Last but not least, the whole Actions mechanism has a logic unto itself. If an operation isn’t recordable by keyboard shortcut, it may be recordable by choosing the menu command instead, or vice versa.

Planning Your Actions

Besides the limits of what you can and cannot record in the Actions panel, there are a few more things to keep in mind when planning actions.

Difficulty. While recording and playing simple actions (those with only two or three steps) may be easy, trying to build complicated actions can be damaging to your head (and the wall you’re banging it against).

Modularity. Rather than trying to make one big action that does everything you want, break it down into smaller steps that you can debug individually and then chain together to reuse in more complex actions.

Think It Through. You should always think the action through completely before you start recording it. You might even write down each step on paper, and then record it after you’re pretty sure everything will work out the way you want.

Generic Actions. Try to make your actions as generic as possible, because there are many specifics that can trip up an action and result in an error. Actions should be able to run on any image at any time. There are a number of things to think about when making your actions generic. The following list is a good place to start:

  • Never assume image mode. The image may be in RGB, CMYK, Grayscale, or even Indexed Color mode. This is very important when running filters, because some filters don’t run in certain modes. You may want to add a step that converts to your intended mode.
  • Don’t assume the image has layers (or doesn’t have layers). Also, don’t assume that if the image does have layers, the Background layer is selected (or even that there is a layer called Background). If you need the lowest layer selected, press Option-Shift-[ (Mac OS X) or Alt-Shift-[ (Windows). You may want to add a step that flattens an image.
  • Avoid using commands that pick layers by name, unless the action creates and names the layer or you are certain the files will always contain a particular name. For example, if you record clicking on a layer in the Layers panel, Photoshop records the click by layer name, not position. Instead, record pressing Option-[ or Option-] (Mac OS X) or Alt-[ or Alt-] (Windows) to target the next layer down or the next layer up, respectively. Command-[ and Command-] (Mac OS X) or Ctrl-[ and Ctrl-] (Windows) move layers up or down, respectively.
  • If you’re saving and loading channels, you’ll almost certainly have to name the channels. Make sure you give them names that are unlikely to already be present in the image. Do name them, though, rather than leaving them set to the default names like “#4”. If a document has two channels with the same name when you run an action, Photoshop always uses the first channel with that name.

Alternatively, you can provide the user with a message at the beginning of the action noting what kind of image is required (as well as other requirements, such as “needs text on a layer” or “must have something selected”). This is a good idea even if you’re the only one using your actions, because (believe us) after you’ve made a bunch of actions, you’ll forget which action requires what (see “Talk to Your Users,” later in this section).

Cleanup. It’s a good idea to make your actions clean up after themselves. In other words, if your action creates three extra channels along the way to building some other cool effect, the action should also probably delete them before ending so that they don’t cause confusion or trip up another action.

Action Basics

Making an action is pretty straightforward:

  1. Open the Actions panel (see Figure 11-36).
    11fig36.jpg

    Figure 11-36 The Actions panel

  2. Click the New Action button (or select New Action from the Action panel menu). Give the action a name (and a keyboard shortcut, if you want). If you have more than one set (see “Sets,” later in this section), choose which set this new action will be part of. When you click OK, Adobe Photoshop begins recording automatically.
  3. Perform the steps that you want the action to do.
  4. Click the Stop button in the Actions panel (or select Stop Recording from the Actions panel menu).

Then, to run the action, select the action’s thumbnail in the Actions panel and click the Run button. Better yet, just Command-double-click (Mac OS X) or Ctrl-double-click (Windows) on the action. If the action is relatively simple, it may perform perfectly the first time. But in most of the actions we make, we find that something goes wrong somewhere along the line, usually due to our performing a step that Photoshop can’t record into an action (see “Troubleshooting Actions,” later in this section).

Save Your Work First. If you run an action and then decide that you don’t like what it did, you’re in trouble, because you cannot undo a full action, only the last step of an action. If the action used only a few steps, you might be able to use the History panel to return to a state before you ran the action, but this isn’t always possible either, particularly if you ran the action as a batch process on multiple files. To guarantee an undo option, we’re in the habit of saving a snapshot of our document in the History panel before running any action. That way, if something goes wrong or we don’t like the effect, we can revert back to this snapshot. Another option is simply to save your document first, and then use the Revert command (in the File menu) to undo the action. Of course, neither of these techniques works with actions that save and close the file—we recommend always making actions that use Save As rather than saving over the original.

Sets. Photoshop lets you create sets of actions, a godsend to anyone who works with dozens of actions. Sets are pretty self-explanatory.

  • To create a new action set, choose New Set from the Actions panel menu (or click the New Set button in the panel). You can delete a set by selecting it and choosing Delete from the same panel menu, or by clicking the Delete button in the panel.
  • To move actions between sets, drag them.
  • To rename a set, double-click its thumbnail in the Actions panel.
  • To show or hide the actions within a set, click the triangle to the left of the set’s name.
  • You can also save sets (see “Saving Actions,” later in this section).
  • To play all the actions in a set (in order), select the set and click the Play button in the Actions panel.

Editing Actions. Once you’ve built an action, you can edit it (in fact, you’ll almost certainly want to edit it unless it worked perfectly the first time). If you want to record additional steps somewhere in the middle of the action (or at the end of the action), select a step in the action and click the Record button. When you’re done recording, click the Stop button. All the new actions fall after the step you first selected.

If you want to add a step that cannot be recorded for some reason (perhaps it’s an item on the View menu), you can select Insert Menu Item from the Actions panel menu. This lets you choose any one feature from a menu, and then inserts it into the action (after the currently selected step).

To change the parameters of a step, double-click on it in the Actions panel. For example, if a step applies a curve to the image (using the Curves dialog), but you want to change the curve, double-click on the step and choose a different curve. Note that when you do this, you may actually change the current image; just press Command-Z (Mac OS X) or Ctrl-Z (Windows) to undo the change (to the image, not to the action).

If you want to change the action’s name, its thumbnail or button color, or its keyboard shortcut, just double-click on the action’s name.

Stop Where You Are. Normally, Photoshop won’t display any of the usual dialogs when you run an action. For instance, if you include a numeric transform step in an action, Photoshop just performs the transform without displaying the dialog. But you can force Photoshop to display the dialog, stop, and wait for the user to enter different settings before continuing. To do so, click once in the second column of the Actions panel, next to the step. A black icon indicating a dialog appears next to the step, and a red icon appears next to the action’s name.

Don’t click on a red dialog icon! If you do, it turns black and Photoshop adds a black “stop here” icon next to every step in the action that can have one. There’s no Undo here, so the only way to reset the little black icons to their original state is to turn them on or off one at a time. (You can, however, turn off all of them by clicking the black icon next to the action’s name.)

Note that if you insert a step using the Insert Menu Item command, Photoshop always opens the appropriate dialog and doesn’t even offer you the chance to turn this icon on or off (because steps inserted in this way are meant to simulate the user actually selecting the item).

Talk to Your Users. You can stop the action at any point and display a dialog with a message in it. This message might be a warning like, “Make sure you have saved your image first,” or instructions such as, “You should have a selection made on a layer above the background.” To add a message, select Insert Stop from the Actions panel menu. Photoshop asks you what message you want to show and whether the message dialog should allow people to continue with the action (see Figure 11-37).

11fig37.jpg

Figure 11-37 Adding a message

If your message is a warning, you should turn on the Allow Continue option, but if you’re communicating instructions, you may want to leave this check box off. When Allow Continue is turned off, Photoshop stops the action entirely. After the user clicks the OK button in the message dialog, Photoshop automatically selects the next step in the Actions panel, so the user can continue running the action by clicking the Run button again (this works even if the Actions panel is in Button mode).

Saving Actions. After you’ve created the world’s most amazing action, you may want to share it with someone else. You can get actions out of your Actions panel and onto your hard drive by selecting Save Actions from the Actions panel menu. Unfortunately, you cannot save a single action; the Save Actions feature only saves sets of actions. The work-around isn’t too painful, however.

  1. Create a new set (click on the New Set button at the bottom of the Actions panel) and name it something logical.
  2. Either move the action you want to save by dragging it, or duplicate it by Option-dragging (Mac OS X) or Alt-dragging (Windows) it into the new action set.
  3. Select the new action set and choose Save Actions from the Actions panel menu.

Of course, you can load sets of actions just as easily with the Load Actions and Replace Actions features in the Actions panel menu. Watch out for Replace Actions and its cousin, Clear Actions; these replace or clear all the actions in the panel, not just the selected one.

Troubleshooting Actions. As we mentioned in Chapter 5, don’t immediately test an action on some mission-critical image. Rather, try it on a dummy image. Even better, try it on several dummy images, each in a different mode (RGB, CMYK, Grayscale, Indexed Color), some with layers, some without, some with selections made, others without, and so on.

Step by Step. You can force Photoshop to pause after each step and redraw the screen by selecting Step by Step in the Playback Options dialog (choose Playback Options from the Actions panel menu). This is often useful, but the best troubleshooting technique in the Actions panel (in fact, probably the only troubleshooting technique) is to select the first item in the action and click the Run button while holding down the Command key (Mac OS X) or Ctrl key (Windows). This plays only the first step. Now go check out all the relevant panels. Is the Channels panel the way you expect it? What about the Layers panel? What are the foreground and background colors? When you’re convinced that all is well, Command-click (Mac OS X) or Ctrl-click (Windows) the Run button again to check the second step in the action, and so on until you’ve tested the entire action. If at any time you find the panels or colors set up improperly, now is the time to replace the last step or double-click on it to change its settings. If something is really messed up, you can fall back on your History snapshot, or revert.

Making Droplets

We’re not sure why the Make Droplet feature is hiding in the File > Automate submenu instead of the Actions panel, but that’s where you can find this really awesome feature. You can use Make Droplet to save any Photoshop action to disk as a file. Then, when you want to process an image (or a folder full of images) with that action, you can simply drag the image (or folder) on top of the droplet file.

If you work in both Mac OS X and Windows, you can copy droplets from one platform to the other. On the PC you simply have to make sure that the droplet has an .exe extension. When you bring a PC droplet to the Mac, you have to initialize it by dragging it on top of the Photoshop application icon, but you have to do that only once.

  • + Share This
  • 🔖 Save To Your Account

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020