Adobe 65048332 Manual page 20

Scripting guide
Table of Contents

Advertisement

C
2: Photoshop Scripting Basics
HAPTER
To create and run your first Photoshop JavaScript:
1. Type the following script.
N
OTE
// Hello Word Script
// Remember current unit settings and then set units to
// the value expected by this script
var originalUnit = preferences.rulerUnits
preferences.rulerUnits = Units.INCHES
// Create a new 2x4 inch document and assign it to a variable
var docRef = app.documents.add( 2, 4 )
// Create a new art layer containing text
var artLayerRef = docRef.artLayers.add()
artLayerRef.kind = LayerKind.TEXT
// Set the contents of the text layer.
var textItemRef = artLayerRef.textItem
textItemRef.contents = "Hello, World"
// Release references
docRef = null
artLayerRef = null
textItemRef = null
// Restore original ruler unit setting
app.preferences.rulerUnits = originalUnit
2. Save file as a text file with a
Photoshop CS5 directory.
N
OTE
accessible from the File > Scripts menu in Photoshop. The scripts do not appear on the File > Scripts
menu until you restart the application.
N
OTE
3. Do either of the following:
If Photoshop is already open, choose File > Scripts > Browse, and then navigate to the Presets >
Scripts folder and choose your script.
Start or restart Photoshop, and then choose File > Scripts, and then select your script from the
Scripts menu.
: Entering comments is optional.
.jsx
: You must place your JavaScripts in the Presets/Scripts folder in order to make the scripts
: Photoshop also supports JavaScript files that use a
file name extension in the Presets/Scripts folder in your Adobe
Creating a sample Hello World script 20
extension.
.js

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

65048599Photoshop cs5

Table of Contents