Subscribe to Tutorial Feed

Flash and PHP Bible

The Flash and PHP Bible has been released! The book can be found on Amazon or wherever fine books are sold in your area.

The Flash and PHP Bible has a forum for quick support.

Scriptplayground » tutorials » pss » Basics of scripting in Photoshop Part 1

Basics of scripting in Photoshop Part 1

Get started with scripting in Photoshop by learning some of the basics.

Scripting has been available for the last few versions of Photoshop, however this is the first time I have had requests for articles. The majority of requests came from attendants of Photoshop World, which gave me the chance to talk with others interested in scripting.

This article is going to focus on the basics of scripting in Photoshop and in later articles we will tackle real world challenges.

All you need to script in Photoshop is a text editor but I recommend the "ExtendScript Toolkit 2" which comes with Photoshop. It is an editor tailored to Adobe scripting and packs a pretty good set of features.

Now that you have the editor open lets look at how we run some code. Of course starting off with "Hello World". Photoshop Scripting, which we will now call "pss" from this point on is actually formed from Javascript and then customized by Adobe.

Create a new script and save it as "HelloPhotoshop.jsx" in the "Presets/Scripts/" folder, which can be found in the install directory of Photoshop. After the new script is created we write a simple bit of code to see the script in action

var helloStr = "Hello Photoshop, how are you doing?";
alert(helloStr);

Normally you would have to restart Photoshop in order for the script to be runnable from the Scripts menu, but for testing you can simply run the script straight from the editor.

Once you run the script you should see your custom message appear in Photoshop, if so congratulations you have written a complete script. Albeit not very useful but it works.

Lets say you want to run this script but really don't want to open the ESTK every time, well Adobe has you covered. Simply place the following 2 lines of code at the beginning of your script and you can now double click it to run in Photoshop. It is also important to note that the script will ask to open Photoshop if it isn't already.

#target photoshop // allow clicking from Finder and Explorer
app.bringToFront(); // run if double clicked

So now our completed script would look like this.

#target photoshop // allow clicking from Finder and Explorer
app.bringToFront(); // run if double clicked

var helloStr = "Hello Photoshop, how are you doing?";
alert(helloStr);

Thats all there is to scripting in Photoshop, now to really get things done the best way is to experiment and refer to the PDF's that Adobe has provided in the "Scripting Guide" folder.

We will be taking this basic usage and expanding it into a small application in the next article. Until then, happy scripting.

Follow Scriptplayground on Twitter (@scriptplay)

Comments: Basics of scripting in Photoshop Part 1

No Comments have been made. Wanna be the first?
Add a comment
The ability to add new comments has been disabled in this archived version.

Loading
Main | Tutorials | Articles