Sign Up Now
Twitter Facebook Flickr Buzz
PhotoshopSociety.org
 
Search:   
 
Social Networks

LOGIN     

Go
Forgot Password? Go Join Now
Sign Up for Starter's Pack (Free)
Call (800) 223-8720
Email custserv@photoshopsociety.org
 
Need Web Solutions? Get Free Sample Issue

Inside Photoshop: Search Articles

  Search Library:  
 
2018 |  2017 |  2016 |  2015 |  2014 |  2013 |  2012 |  2011 |  2010 |  2009 |  2008 |  2007 |  2006 |  2005 | 
 

Demystify the world of scripting in Photoshop

Added on Thursday 27th of January 2005 12:35 am EST
 

Application:

Adobe Photoshop 7/CS

Operating Systems:

Macintosh, Microsoft Windows

 

A great way to save time on common or repetitive Photoshop tasks is to automate them with prepared instructions called scripts. Photoshop CS features enhanced scripting support compared to earlier versions, and the resources for using it are now installed by default (in the past, it was necessary to download scripting extras from the Adobe website or use a third-party plug-in).

You don’t have to be a programming genius to take advantage of Photoshop’s scripting power, but you do have to know where to look. A wealth of resources may already be hiding on your hard drive, including several collections of useful scripts that you can put to work right away.

 

Stick to the script

In this article, we’ll introduce you to Photoshop’s scripting features. We’ll start by explaining what scripts are, what they do, and how they differ from Photoshop Actions. Next, we’ll compare the three scripting languages that can automate Photoshop functions. Then, we’ll explain the uses of the Scripts menu. Finally, we’ll show you where to find sample scripts and code segments that you can adapt for your own needs.

 

What scripts are and what they do

A script is basically a set of instructions for Photoshop and other applications on your computer. They’re especially useful for batch-processing or applying multi-step effects that you use on a regular basis. In Photoshop, for example, you might use a script to convert the color mode of a group of files, or apply a sequence of filters and layer effects to a single document. 

Creating and testing new scripts can be a time-consuming process, but it pays off quickly in increased productivity. With just a click or two, you can launch a script that performs many tasks automatically, while you do other work or grab a latté. With this basic concept in mind, let’s review the differences between scripts and Photoshop Actions.

 

Scripts are more versatile than Actions

On the surface, scripts may seem similar to Photoshop Actions. Both tools can automate many of the same functions, but scripts differ from Actions in several key ways:

   While an Action strings a single series of menu commands together, scripts can analyze a document or application environment and make decisions based on the results. For example, a script can be instructed to create a new document if an existing one isn’t already open.

   Scripts can interact with other scriptable applications outside Photoshop. You could, for example, write a script that converts a group of images to JPEG format, creates thumbnails for the web, lays out a contact sheet in Adobe® Illustrator® or Adobe® InDesign®, and sets up a gallery page for the same images in Adobe® GoLive®.

   Unlike Actions, you can’t tell a script to record what you do while you work. However, you can still record segments of your task as an Action, and then instruct the script to execute that Action. This method has one drawback: If someone else wants to use your script, he must have a copy of any Actions it invokes on his computer.

 

Now that you have a basic understanding of the difference between scripts and actions, let’s take a look at the different scripting languages that work with Photoshop.

 

Know your scripting options

The designers of Photoshop and other applications do a lot of work behind the scenes to make sure scripts can function. The more scripting support programmers build into an application, the more sophisticated tasks it can perform.

With its robust automation support, Photoshop CS is one of the most scriptable applications around. In addition, Adobe supports three of the most popular scripting languages in use today:

   AppleScript. An intuitive scripting language for the Macintosh platform. The Script Editor application for creating AppleScripts is preinstalled on every Mac. Best of all, it’s free. Third-party applications with more sophisticated editing and debugging features are also available.

   Visual Basic. The scripting standard for Windows-based PCs. Users who prefer this platform need a Visual Basic editor, such as the Microsoft Windows Scripting Host or Microsoft Visual Basic.

   JavaScript. Photoshop provides built-in, platform-independent support for JavaScript. Unlike scripts in other languages, JavaScripts run with identical results on Mac and Windows machines. The tradeoff is that JavaScripts can’t interface with other applications. You can write JavaScripts with any text editor, but you must save them with the file extension .js to function with Photoshop’s controls.

 

You can also use other scripting languages. You can use any language that sends Apple Events on a Mac or is COM-aware on a Windows computer to script Photoshop. You can run scripts written in Visual Basic or AppleScript using their respective software, or save them as standalone applications. To run JavaScripts, you’ll need to use the Scripts menu, as detailed in the next section.

 

Use the Scripts menu

Formerly located in the File > Automate submenu, the Scripts menu is now found directly under the File menu in Photoshop CS, as shown in Figure A.