Real World Adobe® Photoshop® CS2 [Electronic resources] : Industrial-Strength Production Techniques نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Real World Adobe® Photoshop® CS2 [Electronic resources] : Industrial-Strength Production Techniques - نسخه متنی

Bruce Fraser, David Blatner

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید












Actions, Automate, and Scripting


The trick to being really productive and efficient with computer technology is being lazy. Yes, it's a paradox, but it's truethe 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. If you have an overzealous work ethic, you probably don't mind repeating the same mind-numbing tasks 400 times, but you won't be exploiting the power of the computer in front of you.

For example, Bruce works with a lot of digital cameras, and each digital camera's images need a particular kind of tweaking. Rotate the image 90 degrees, run this filter, use that Curves setting, resize the image to such-and-such.... Instead of performing each task one at a time, he can run through them all with a keystroke. Even better, Photoshop's automation features let you batch process all the images in a folder, so you don't even have to open them in Photoshop.

As Photoshop gets smarter with each new version, we can offload more busywork onto it while we take longer trips to the fridge for artichoke dip. (We're just hoping that Photoshop doesn't get too smart and starts making us do the work while it gets the dip.)

Photoshop offers four automation features: actions, Automate, Variables, and scripting. Actions are "macros" that live in the Actions palette and let you repeat a series of steps. 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 Automate submenu (under the File menu). Variables is a way to create a template image that changes depending on data imported from a spreadsheet or a database. Scripting is a way to automate Photoshop from behind the scenes using AppleScript, JavaScript, or Visual Basic. We'll look at each of these techniques in turn.


Actions


In the last chapter, we discussed the basics of building actionsparticularly 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, too, 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 palette's popout menu, or by choosing the presets that appear at the bottom the popout menu.)

The key is that you can only make an action for something you can do methodically, 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." That would require Photoshop 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.

Tip: Exporting Actions as Text

Trying to decode how other people made actions can be a hassle because the Actions palette is hard to read. Fortunately, you can export all the actions currently visible in the palette as a text file that you can open in a word processor: just hold down Command and Option while selecting Save Action from the Actions palette's popout menu.


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. While Photoshop can record blend modes, opacity, shapes, brush selections, and even pixel selections, you still cannot record paint strokes (like those made with the Brush, Airbrush, and Clone tools), zooms, switching windows, and scrolls. And there are many features that aren't necessarily recordable, but you can force them 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.


Keep in Mind


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


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, 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 think.


Generic actions


Try to make your actions as generic as possible. That means they should be able to run on any image at any time. Or, barring that, 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 "Tip: Talk to Your Users," later in this chapter).

There are a number of things to think about when making your actions generic. The following is a good place to start, but isn't necessarily a complete list:

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.

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-[.

Avoid using commands that pick layers by name, unless the Action has already created and named the layer. For example, if you record clicking on a layer in the Layers palette, Photoshop records the click by layer name, not position. Instead, record pressing Option-[or Option-] to target the next layer down or the next layer up, respectively. Command-[and Command-] move layers up or down.

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.



Clean up


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. If the action hasn't cleaned up after itself and you run it a second time, those channels (or layers, or whatever) are still hanging around and will probably trip up the action.


Get more info


This section offers a quick overview of actions, but if you have Web access, check out one or more of the actions-oriented sites on the Internet like [ http://share.studio.adobe.com ]. You can also find more links from a site such as [ www.photoshopnews.com ].


Actions Basics


Making an action is pretty straightforward:


1.

Open the Actions palette (see Figure 12-60).


Figure 12-60. The Actions palette

[View full size image]

2.

Click the New Action button (or select New Action from the palette's popout 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 chapter), 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 palette (or select Stop Recording from the popout menu).


Then, to run the action, select the action's tile in the Actions palette and click the Run button (or, better yet, just Command-double-click 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).

Tip: 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 palette to return to a pre-action state, 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 palette 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 to simply 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 filewe recommend always making actions that use Save As, rather than saving over the original.

Tip: Making Buttons

You can change the Actions palette into a palette full of buttons by choosing Button Mode in the palette's popout menu. When it's in Button mode, you only have to click once on a button to run it. Switch out of Button mode to create new actions or edit existing ones.


Sets


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

You can create a new action set by choosing New Set from the Action palette's popout menu (or by clicking the New Set button in the palette). You can delete a set by selecting it and choosing Delete from the same popout menu, or by clicking the Delete button in the palette.

You can move actions between sets by dragging them.

You can rename a set by double-clicking on its tile in the Actions palette.

You can show or hide the actions within a set by clicking on the triangle to the left of the set's name.

You can also save sets (see "Saving actions," a bit later).

You can play all the actions in a set (in order) by selecting the set and clicking the Play button.



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 actions, 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 in the View menu), you can select Insert Menu Item from the Action palette's popout menu. This lets you choose any one feature from the menus, and then inserts it into the action (after whatever step is currently selected).

To change the parameters of a step, double-click on it in the Actions palette. For example, if a step applies a curve to the image (using the Curves dialog box), 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 to undo the change (to the image, not to the action).

Annoyingly, some steps cannot be re-recorded. For instance, a step that sets the foreground color to red should be able to change so that it sets it to blue... but it can't. Instead, you have to record a new step, then delete the original.

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

Tip: Duplicating Actions

Option-dragging a step duplicates it. For instance, if you want to use the same Numeric Transform step in two actions, you can Option-drag that step from one action into the proper place in the second action.

Tip: Stop Where You Are

Normally, Photoshop won't display any of the usual dialog boxes 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 box. But you can force Photoshop to display the dialog box, stop, and wait for the user to input different settings before continuing. To do so, click once in the second column of the Actions palette, next to the step. A black icon indicating a dialog box appears next to the step, and a red icon appears next to the action's name.

Don't click on a red dialog box 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 them all off 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 box 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).

Tip: Talk to Your Users

You can insert a command at any point in your action that stops the action and displays a dialog box 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 palette's popout menu. Photoshop asks you what message you want to appear and whether the message dialog box should allow people to continue with the action (see Figure 12-61).


Figure 12-61. Adding a message

If the message is a warning, you should turn on the Allow Continue option, but if the message consists of instructions, you may want to leave this checkbox off. When Allow Continue is turned off, Photoshop stops the action entirely. After the user clicks the OK button in the message dialog box, Photoshop automatically selects the next step in the Actions palette, so the user can continue running the action by clicking the Run button again (this works even if the Actions palette 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 palette and on to your hard drive by selecting Save Actions from the Actions palette's popout menu. Unfortunately, you cannot save a single action; the Save Actions feature only saves sets of actions. Fortunately, the workaround isn't too painful.


1.

Create a new set (click on the New Set button at the bottom of the Actions palette), and name it something logical.

2.

Either move or duplicate the action you want to save by dragging it or Option-dragging it into the new set.

3.

Select the new set and choose Save Actions from the palette's popout menu.

4.

If you want, delete the set you just created.


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

Tip: Curves and Adjustments

We love the fact that Photoshop can record the exact settings of the Curves, Levels, and Hue/Saturation dialog boxes. Nonetheless, you should note that if you record loading a Curves file from disk (or a Levels or Hue/Saturation file, or any other adjustment), Photoshop records the name of the file rather than the curve itself.

The workaround: record loading the setting in the Curves dialog box (or whatever), then change the settings just a tiny bit before clicking OK. As long as there is a difference, Photoshop records the settings in the dialog box rather than the file's name. Remember that you can always go back and change the settings back to the way you want them.


Troubleshooting Actions


Sometime, somewhere, something will go wrong when you're building actions. That's where troubleshooting comes in. When troubleshooting (or debugging, as it's often called), the most important thing to keep in mind is that there must be a logical solution to the problem. (This isn't always true, but it's good to keep a positive attitude....)


Dummy files


The first thing you should do after building an action is not test it 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. If it doesn't operate correctly on any one of these, you can decide whether to work at making it work or to add a message at the beginning of the action that says "don't try it on such-and-such-type of images" (see "Tip: Talk to Your Users," earlier in this section).


Step-by-step


You can force Photoshop to pause between each step and redraw the screen by selecting Step-By-Step in the Playback Options dialog box (you can choose this from the popout menu in the Actions dialog box). This is often useful, but the best troubleshooting technique in the Actions palette (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. This plays only the first step. Now go check out all the relevant palettes. Is the Channels palette the way you expect it? What about the Layers palette? What are the foreground and background colors?

When you're convinced that all is well, press Command-Run again to check the second step in the action. And so on, and so on....

If at any time you find the palettes 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, then don't forget the Revert feature.

Tip: Use History

The History palette, when suitably configured, lets you step backwards through all the steps in an action, making it a great deal easier to figure out just where things went awry. So much so, in fact, that we wouldn't dream of trying to debug complex actions without it. The key is simply to make sure that you set Photoshop's Preferences to record a large enough number of History states to cover all the steps in the action.


Automated Workflows


Earlier we said that actions cannot perform any task that requires brain activity. However, Adobe's engineers have built some automation tools that do have some "smarts" and placed them in two places: in the Automate submenu (under the File menu) and in the Bridge's Tools menu. These menus are also home to the Batch feature, which lets you run an action on an entire folder of images. Let's take a quick look at some of these options.

Chapter 14, Multimedia and the Web. We also explore the Automate menu, and especially the oft-infuriating Batch command, in Chapter 11, Building a Digital Workflow.)

Tip: Making Droplets

We're not sure why the Make Droplet feature is hiding in the Automate submenu instead of the Actions palette, 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.

Bonus tip: If you work on both Macs and PCs, you can copy droplets from one platform to the other. On the PC you simply have to make sure the droplet has an .exe extension. When you bring a PC droplet to the Mac, you have to initialize it once by dragging it on top of Photoshop.


Picture Package


Picture Package is a boon to any photographer tired of duplicating, rotating, and scaling photos to fit pictures on one sheet of film. You can use Picture Package to lay out different versions of the same picture (like school photos, where you want so-many wallet-sized, and so on). Or you can use it to lay out different images together onto one page. The interface is simple enough to understand quickly (see Figure 12-62), though there are a few things to watch out for:

First off, make sure you pay attention to the final resolution and final image mode setting. The default resolution, 72 dpi, leaves a great deal to be desired if you're planning to print your page.

If you want all the images on the page to be the same, just select File from the Use popup menu and then click the Choose button to select your file. If you want different images, you can click on one or more of the preview images in the lower-right area of the dialog box.

Photoshop lets you choose a label to add to the images. However, the choices are pretty slim. For instance, the label is always added on top of the image (there's no way to get it in a margin), the fonts are limited, and there are no options for styles (like drop shadows or glow around the label to make it stand out better).

If you choose more than one image (either by selecting Folder from the Use popup menu, or by selecting more than one image in Bridge and setting the Use popup menu to Selected Images in Bridge), Picture Package doesn't lay them out on the same page; it prepares one page for each image. Unfortunately, there doesn't appear to be any way to preview more than one page at a time, so we generally avoid selecting more than one image when using this feature.

Note that the final result is not a flattened file, but rather all the images on a single floating layer. This means you can easily change the color behind the images, but it also means that you may need to flatten the file before printing or exporting the document.



Figure 12-62. Picture Package

[View full size image]

Tip: Customized Package Pages

Photoshop offers about 20 different Picture Package layouts, but in case you just gotta' be you, you're welcome to create your own customized layouts, too. Photoshop sports a nifty layout editor (select an example template from the Layout popup menu and then click the Edit Layout button in the lower-right corner of the Picture Package).

The Edit Layout dialog box (see Figure 12-63) works like a basic drawing program: First choose a page size that corresponds to your printed paper size in the Layout area. Then, click on a box (a "zone") to move it or change its size. You can remove a zone by clicking the Delete Zone button, or add one by clicking Add Zone. Unless you're really going wacky and wild, do yourself and everyone around you a favor and turn on the Snap To checkbox so that as you drag or resize a zone it snaps to a grid line; the grid is based on the value in the Size field.


Figure 12-63. Customizing Picture Package

[View full size image]

When you're done, give your layout a name and click Save. Photoshop knows just where to save these files (in the Photoshop>Presets>Layouts folder), so you just need to name your file (probably something similar to your layout name) and click Save. The layout name is what appears in the Layout popup menu; the filename is just the on-disk filename.


Contact Sheet II


Contact Sheet builds pages of thumbnails from a folder full of images (see Figure 12-64). In ancient versions of Photoshop, Contact Sheet wouldn't actually label any of the images, making the contact sheet somewhat unusable. That has changed; on the other hand, Photoshop doesn't know what to make of long filenames, and usually truncates them. With any luck, Contact Sheet III will give you even more controls (though who knows when that will show up).


Figure 12-64. Contact Sheet II

[View full size image]


Crop and Straighten Photos


The Automate features are designed to save you from mind-numbing grunt work, and the Crop and Straighten Photos feature fits that bill exactly. If you throw four photos on a flatbed scanner, you can either scan four times (adjusting the scanning area each time) or scan once, duplicate the resulting file three times, and crop each one a unique image. Now you've got another choice: Scan once and choose Crop and Straighten Photos from the Automate submenu. This feature does the work for you by analyzing the image, duplicating it, cropping it, and rotating each one so that it sits straight. If you decide you only want a couple of the images on the page, draw selection marquees around the ones you want, and Photoshop will focus on them.

Obviously, the more clearer the boundaries are between the images the better the feature works. Crop and Straighten Photos usually works quite well, but we've found we sometimes still need to do a little cropping cleanup on some images (especially old photos that don't have clearly defined boundaries or in contact sheets with black borders). On rare occasions, Photoshop breaks an image into two or more pieces (if the colors in the image have areas that are too similar to the color around the images). In that case, make a selection around the image and then hold down Option/Alt while selecting the feature from the Automate submenu.


Using Variables


Most folks don't tend to think of Photoshop as a tool for making templates that will be filled in with content at a later date, but the Variables feature should change that. Variables lets you turn a static Photoshop document into a dynamic one that can change based on information stored in a database or spreadsheet. For example, you might have 300 photographs of products for your catalog and you want to place each product's price on top of its image. In addition, perhaps you want to place a starburst over the products that are new in this year's catalog. You can use variables to perform this task with no special scripting knowledge.

There are three kinds of variables in Photoshop: visibility (whether a layer is visible or not), text (the text that appears on a text layer), and picture (the image that appears on a layer). To set up the example above, you could make a four-layer Photoshop file: the blank background layer; another layer filled with white; a text layer with any random text on it in the size, style, and position you want the price to appear; and a layer with a "New!" starburst image on it. After you create this template:


1.

Choose Define from the Variables submenu (under the Image menu; see Figure 12-65).


Figure 12-65. Variables

[View full size image]

2.

Choose the layer you want to define as a variable from the Layer popup menu.

3.

In the Variable Type section, select either Visibility, Text Replacement (if it's a text layer), or Pixel Replacement (if it's a normal layer), and give the variable a name in the appropriate Name field.

4.

Repeat steps 2 and 3 for each layer you want to be variable.

5.

Choose Data Sets from the popup menu at the top of the dialog box. A data set is like a single record in a databaseit provides the data for what to do with the variables. You can use the controls here to build your own data set, or you can click the Import button to load a set of records from a database or a spreadsheet. You can find the details for how to build a file to import in the Photoshop help files. If you only have a small number of data sets, you can create them manually by clicking the New Data Set button and then choosing each variable in order from the Variables section.

6.

When you are done with the data sets, click OK. To load a single data set, choose Apply Data Set from the Image menu. If you want to create all the data sets, creating a new Photoshop PSD file for each one, choose Data Sets as Files from the Export submenu (under the File menu).



Scripting Photoshop


If actions and variables got you all excited about automating Photoshop, you're going to love scripting. Scripting is a way for one application (or your system) to talk to another application behind the scenes. For instance, in Mac OS X 10.3 or later, you can attach a script to a folder, so that as soon as you drop an image into the folder, your system launches Photoshop, performs several operations on it, saves the file, and then closes it again; it's all handled automatically.

Scripting is one of the coolest features in Photoshop, and it works on both the Macintosh and Windows platforms, but almost no one knows about it because Adobe doesn't advertise it well.


Scripting vs. actions


There are four basic differences between actions (which are also called macros) and scripts. First, actions are entirely dependent on the user interfacethe menus, dialog boxes, keyboard shortcuts, and so on. Scripts, however, let you sneak in the back door of the program and control it from behind the scenes, almost like a puppeteer pulling the strings of a marionette. Second, scripts have flow control. Flow control is a programming term that means you can set up decision trees and loops, like "keep doing this until such-and-such happens." Third, scripts often contain variables, so you can save the value of something (like the color of a pixel) to use it later.

Last, scripting lets you control more than one program at time. For example, if you use QuarkXPress (which is also scriptable on the Macintosh) or InDesign (which is scriptable on both Macintosh and Windows), you could write a script that would automatically "see" how you've rotated, sized, and cropped images within your picture boxes. It could then open the images in Photoshop, perform those manipulations on the original images, resave them, and re-import them into the page-layout program. Powerful stuff!

Tip: Hiring a Scripter

Even though scripting is extremely powerful, it's just a fact of life that most people don't want to learn the ins and outs of scripting. Fortunately, there are a number of scripters for hire. You can find a good scripters on Adobe's scripting forum: [ www.adobe.com/support/forums/ ]. If you're looking for a scripter for the Macintosh, there are also consultants listed at [ www.apple.com/applescript/resources/ ].


Scripting languages


You can script Photoshop using a number of different languages. On the Macintosh, you can use AppleScript or JavaScript. In Windows, you can use JavaScript, Visual Basic, or any other language that is COM aware, such as VBScript, Perl, or Python. Note that only JavaScript scripts can be used cross-platform. That would seem to make it the best option for scripting, but unfortunately, only a few other applications are JavaScript-awareAdobe InDesign (CS and CS2) and Adobe Bridge are, but QuarkXPress is not.


First steps in scripting


We don't pretend that we can actually teach you how to script Photoshop in this book. Although we believe that almost anyone can learn how to write scripts (especially using AppleScript, which is much easier than other forms of scripting), scripting is still a form of computer programming and as such, it takes time and patience to learn. So where can you learn it?

Books. Several good books have been published on scripting. Most are pretty general, such as Matt Neuburg's AppleScript: The Definitive Guide, the AppleScript for Applications Visual QuickStart Guide, and Visual Basic Visual QuickStart Guidethese don't discuss Photoshop's scripting, but they'll get you up to speed so that Adobe's own documentation makes a lot more sense. You might also look at Sal Soghoian's book AppleScript 1-2-3Sal knows everything there is to know about the subject.

Examples. The best way to learn how to script Photoshop is by first looking at and deconstructing other people's scripts. If you can find a script that already does what you want, then use it. If the script isn't quite right, then edit it to make it work for you. Adobe has provided a number of scripts to play with, including scripts that add text, warp it, and then convert the text to a selection. You can open AppleScripts in Script Editor (the free AppleScript editor that comes with the Macintosh), and Windows scripts in any Visual Basic editor in Windows to see how they work or edit them to suit your needs. JavaScripts are just text, so you can use any text editor to read or write them.

You can find even more scripts on Web sites, such as the Adobe Studio Exchange at [ share.studio.adobe.com ].

Scripting dictionary. On the Macintosh, all scriptable applications have a built-in scripting dictionary that outlines the various things that can be scripted in that program. One way to see this information is by choosing Open Dictionary in the File menu of the Script Editor utility. The dictionary is often most helpful as a quick reference when your books or documentation isn't around.

The Web. The World Wide Web is, of course, one of the best sources for AppleScript, Visual Basic, and JavaScript information. There are a number of great sites out there that offer both tutorials on scripting and scripts that you can download, use, and learn from. If you want AppleScript information, the best place to start, of course, is Apple's own scripting site: [ www.apple.com/applescript ]. Another excellent place to learn about scripting is the Photoshop Scripting forum on Adobe's own Web site at [ www.adobe.com/support/forums/mai207 ], or here: [ www.ps-scripts.com/ ].



Running scripts


Even if you never find yourself writing scripts, you're missing out if you don't know how to run themthe example scripts that Adobe provides are extremely helpful. AppleScript and Visual Basic scripts must be run from outside of Photoshop, from a program like Script Editor (which ships free with all Macs).

JavaScript scripts are even more flexible: The easiest way to run a JavaScript from within Photoshop is to place it in the Photoshop/Presets/Scripts folder. Photoshop lists these files in the Scripts submenu, under the File menu (see Figure 12-66). If your script doesn't live in that folder, you can tell Photoshop where to find it by selecting Browse from the Scripts submenu.


Figure 12-66. Running JavaScripts

Web Photo Gallery." We cover these galleries in more detail in Chapter 14, Multimedia and the Web.


Tip: Running Scripts on Events

In the previous chapter, we described an action that would add several adjustment layers to a bunch of files in a batch process. Another way of going about this is to apply this action as an event script, which runs each time you perform a task such as opening a document. (Yes, event scripts work with both scripts and actions.) To create an event script, choose Scripts Events Manager from the Scripts submenu (under the File menu) and turn on the Enable Events to Run Scripts/Actions checkbox (see Figure 12-67).


Figure 12-67. Run a script on an event

[View full size image]

Next, choose an event from the Photoshop Event popup menusuch as Open Document, Save Document, or Start Application. (You can also add your own events if you understand the Photoshop scripting model well enough.) Now choose a Script or Action at the bottom of the dialog box.

When you click Done, Photoshop starts "listening" for your event to take place. As soon as you perform the event, the action or script is triggered. For example, you might have a script that opens a set of files each time you launch Photoshop and an action that creates a thumbnail and saves it as a JPEG each time you open a document. But remember to come back and turn off the checkbox at the top of this dialog box if someone else is going to use your copy of Photoshop. Otherwise, they'll be mighty confused as to why Photoshop is acting so oddly.

Tip: Hard-Core Scripting

If you really get into writing scripts, you will find yourself spending a lot of time writing or debugging scripts and you will want to take a look at some of the other scripting applications on the market. For instance, Late Night Software's Script Debugger is a full-featured tool that helps you write and debug AppleScripts, and is better than Apple's rather spartan Script Editor. Adobe's ExtendScript Toolkit (which ships with the Creative Suite), is very helpful when writing JavaScripts.

Also, the more complicated a script, the more it requires a way for the user to interact with itbuttons, text fields, dialog boxes, and so on. If you're interested in building user interfaces for your AppleScripts, take a look at Apple's own AppleScript Studio. In Windows, you can build interfaces using Visual Basic. For JavaScript scripts, see the JavaScript Reference Guide that comes with Photoshop for details.

Tip: Scripting the Unscriptable

Sadly, not everything in Photoshop is scriptable at this time, and some features are scriptable using JavaScript, but not via AppleScript or Visual Basic. This will change in time, but in the meantime, there are two options workaround. First, you can create an action in the Actions palette that performs that one step, and then trigger that action inside the script.

The second choice is to use the ScriptingListener plug-in, which comes with the Scripting Support files. When this plug-in is loaded, it can actually write a JavaScript of whatever you do in Photoshop. For instance, you can open a new document, make a selection, fill it with a gradient, and save the file to disk. The ScriptingListener writes the JavaScript for those commands to disk for you (Java Script files are just text files that can be edited in any text editor program). Then you can tell your AppleScript or Visual Basic script to run this little JavaScript code at the appropriate time.


/ 219