Scripting Guide
Page 6
...Script Object Model Viewer, see the JavaScript Tools Guide. When referring to execute scripts, and the Photoshop object model. Code examples are used when referring to scripting Adobe® Photoshop® CS4 on page 22. Conventions in this Guide Code and specific language samples appear in monospaced courier font... Manager, which allows you to commands in AppleScript and methods in this manual. For information about outstanding issues. See "Viewing Photoshop's AppleScript dictionary" on page 21 and "Viewing Photoshop's type library (VBS)" on Mac OS® and Windows®.
...Script Object Model Viewer, see the JavaScript Tools Guide. When referring to execute scripts, and the Photoshop object model. Code examples are used when referring to scripting Adobe® Photoshop® CS4 on page 22. Conventions in this Guide Code and specific language samples appear in monospaced courier font... Manager, which allows you to commands in AppleScript and methods in this manual. For information about outstanding issues. See "Viewing Photoshop's AppleScript dictionary" on page 21 and "Viewing Photoshop's type library (VBS)" on Mac OS® and Windows®.
Scripting Guide
Page 8
... example, you could write a script to generate a number of localized versions of a particular image or to skip much of this installation: Adobe Photoshop CS4 AppleScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 JavaScript Scripting Reference. The actions can do manually. If you've used by allowing you should acquaint yourself with this chapter...
... example, you could write a script to generate a number of localized versions of a particular image or to skip much of this installation: Adobe Photoshop CS4 AppleScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 JavaScript Scripting Reference. The actions can do manually. If you've used by allowing you should acquaint yourself with this chapter...
Scripting Guide
Page 10
...folders. ➤ On Windows, the startup folder for user-defined scripts is: C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for execution. Only .js or .jsx files are displayed in the Scripts ...-defined scripts is: ~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop If your JavaScripts. Startup scripts On startup, Photoshop executes all other scripts The Browse item at startup. CHAPTER 2: Photoshop Scripting Basics Scripting Support in Photoshop 10 Scripts written in this main startup ...
...folders. ➤ On Windows, the startup folder for user-defined scripts is: C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for execution. Only .js or .jsx files are displayed in the Scripts ...-defined scripts is: ~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop If your JavaScripts. Startup scripts On startup, Photoshop executes all other scripts The Browse item at startup. CHAPTER 2: Photoshop Scripting Basics Scripting Support in Photoshop 10 Scripts written in this main startup ...
Scripting Guide
Page 16
..., the constant is PSLayerKind, for commands or methods. CHAPTER 2: Photoshop Scripting Basics Photoshop Object Model 16 Additional objects The Photoshop object model includes additional objects beyond the ones described in the Adobe Photoshop CS4 Visual Basic Scripting Reference. See "Working with different constant values.... scripting engine. The constant values for the property. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. For example, with the kind property of an Art Layer object...
..., the constant is PSLayerKind, for commands or methods. CHAPTER 2: Photoshop Scripting Basics Photoshop Object Model 16 Additional objects The Photoshop object model includes additional objects beyond the ones described in the Adobe Photoshop CS4 Visual Basic Scripting Reference. See "Working with different constant values.... scripting engine. The constant values for the property. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. For example, with the kind property of an Art Layer object...
Scripting Guide
Page 18
... properties ¬ {width:4 as inches, height:2 as inches} set kind of artLayerRef to Scripting, which has a section on AppleScript debugging. set its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- NOTE: The default location for the Script Editor is optional. -- Create a new document and art layer. Get a reference to the text object and set...
... properties ¬ {width:4 as inches, height:2 as inches} set kind of artLayerRef to Scripting, which has a section on AppleScript debugging. set its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- NOTE: The default location for the Script Editor is optional. -- Create a new document and art layer. Get a reference to the text object and set...
Scripting Guide
Page 20
.... NOTE: Entering comments is already open, choose File > Scripts > Browse, and then navigate to make the scripts accessible from the Scripts menu. NOTE: Photoshop also supports JavaScript files that use a .js extension. 3. var textItemRef = artLayerRef.textItem textItemRef.contents = "Hello, World" // Release references docRef = null.... Save file as a text file with a .jsx file name extension in the Presets/Scripts folder in Photoshop. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory.
.... NOTE: Entering comments is already open, choose File > Scripts > Browse, and then navigate to make the scripts accessible from the Scripts menu. NOTE: Photoshop also supports JavaScript files that use a .js extension. 3. var textItemRef = artLayerRef.textItem textItemRef.contents = "Hello, World" // Release references docRef = null.... Save file as a text file with a .jsx file name extension in the Presets/Scripts folder in Photoshop. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory.
Scripting Guide
Page 21
... also lists the parameters for more information. You will help you quickly understand how to view the Photoshop AppleScript Dictionary. ➤ For VBScript, use the VBA editor in Microsoft Word, or the Visual Basic Object Browser in... three scripting languages is found in the reference manuals provided in this installation: ➤ Adobe Photoshop CS4 AppleScript Scripting Reference ➤ Adobe Photoshop CS4 Visual Basic Scripting Reference ➤ Adobe Photoshop CS4 JavaScript Scripting Reference In addition, you can also access reference material by instructions for locating ...
... also lists the parameters for more information. You will help you quickly understand how to view the Photoshop AppleScript Dictionary. ➤ For VBScript, use the VBA editor in Microsoft Word, or the Visual Basic Object Browser in... three scripting languages is found in the reference manuals provided in this installation: ➤ Adobe Photoshop CS4 AppleScript Scripting Reference ➤ Adobe Photoshop CS4 Visual Basic Scripting Reference ➤ Adobe Photoshop CS4 JavaScript Scripting Reference In addition, you can also access reference material by instructions for locating ...
Scripting Guide
Page 22
... 2. Select it. 5. Click OK. 7. Choose Photoshop CS4 type library from the Photoshop application itself. (See "Creating and running a JavaScript" on the plus sign next to display more information abut the class. On the COM tab, find "Adobe Photoshop CS4 Object Library". You can use the object browser in... the Visual Basic development environment to display the objects and commands available for VBScript in Photoshop. NOTE: In JavaScript, you open the scripts from ...
... 2. Select it. 5. Click OK. 7. Choose Photoshop CS4 type library from the Photoshop application itself. (See "Creating and running a JavaScript" on the plus sign next to display more information abut the class. On the COM tab, find "Adobe Photoshop CS4 Object Library". You can use the object browser in... the Visual Basic development environment to display the objects and commands available for VBScript in Photoshop. NOTE: In JavaScript, you open the scripts from ...
Scripting Guide
Page 23
..., you do not reference the Application object. Therefore, you must enclosing your script in the following statements: tell application "Adobe Photoshop CS4" ... end tell NOTE: Because you include all commands in the tell block, there is not possible to add a new Preferences object.) ... in a script, you name the type of object you want to the art layers collection. CHAPTER 3: Scripting Photoshop Creating New Objects in a Script 23 AS To target Photoshop in AppleScript, you must reference the Document object when adding objects other than Document and Notifier objects to your script...
..., you do not reference the Application object. Therefore, you must enclosing your script in the following statements: tell application "Adobe Photoshop CS4" ... end tell NOTE: Because you include all commands in the tell block, there is not possible to add a new Preferences object.) ... in a script, you name the type of object you want to the art layers collection. CHAPTER 3: Scripting Photoshop Creating New Objects in a Script 23 AS To target Photoshop in AppleScript, you must reference the Document object when adding objects other than Document and Notifier objects to your script...
Scripting Guide
Page 24
... new document You can be a "Valid Commands" list at the end of the object name, as in the Adobe Photoshop CS4 AppleScript Scripting Reference. VBS In VBScript, you must reference both the Application and Document objects that contains the object. CHAPTER 3: Scripting... sample statement, the Application object is to a new document. To add an ArtLayer object, you can use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in an AppleScript: ➤ Look up the object in the following sample, which creates a Document object: appRef.Document...
... new document You can be a "Valid Commands" list at the end of the object name, as in the Adobe Photoshop CS4 AppleScript Scripting Reference. VBS In VBScript, you must reference both the Application and Document objects that contains the object. CHAPTER 3: Scripting... sample statement, the Application object is to a new document. To add an ArtLayer object, you can use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in an AppleScript: ➤ Look up the object in the following sample, which creates a Document object: appRef.Document...
Scripting Guide
Page 25
...ActiveDocument or ActiveLayer). ➤ In JavaScript, you use the add() method only with the Add method on a an object in the Adobe Photoshop CS4 JavaScript Scripting Reference. Similarly, the ArtLayer object does not have an Add() method; Setting the Active Object To work in a layer, ...is not valid with the Document object. the ArtLayers object does. For more information, look up in the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the script. The add() method is good programming practice to the previous sample: app.documents.add...
...ActiveDocument or ActiveLayer). ➤ In JavaScript, you use the add() method only with the Add method on a an object in the Adobe Photoshop CS4 JavaScript Scripting Reference. Similarly, the ArtLayer object does not have an Add() method; Setting the Active Object To work in a layer, ...is not valid with the Document object. the ArtLayers object does. For more information, look up in the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the script. The add() method is good programming practice to the previous sample: app.documents.add...
Scripting Guide
Page 26
... is the parent of current, and so on. Similarly, if you look at the Application object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Photoshop AppleScript Dictionary, you would include command statements --that set active objects, see the following sections. ➤ "...the Document object, you would include command statements 'that contains the specified object. if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you find one of the application class to docRef --here...
... is the parent of current, and so on. Similarly, if you look at the Application object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Photoshop AppleScript Dictionary, you would include command statements --that set active objects, see the following sections. ➤ "...the Document object, you would include command statements 'that contains the specified object. if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you find one of the application class to docRef --here...
Scripting Guide
Page 27
appRef.ActiveDocument = docRef docRef.ActiveLayer = docRef.Layers(1) Look up the activeLayer property on the Document object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser. AS set current layer of current document to layer "Layer 1"...// This example assumes docRef has been previously defined and assigned to a // document object that perform actions on the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer. NOTE: You can also use the name of the layer to indicate ...
appRef.ActiveDocument = docRef docRef.ActiveLayer = docRef.Layers(1) Look up the activeLayer property on the Document object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser. AS set current layer of current document to layer "Layer 1"...// This example assumes docRef has been previously defined and assigned to a // document object that perform actions on the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer. NOTE: You can also use the name of the layer to indicate ...
Scripting Guide
Page 29
...Reference look up the Photo CD open options class or the EPS open objects class. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or the Adobe Photoshop CS4 JavaScript Scripting Reference, look up the PhotoCDOpenOptions or EPSOpenOptions objects. Specifying file formats to open Open Classes Open Options...document is opened, which page to open to in a multi-page file, etc. ➤ PhotoCD ➤ CameraRaw ➤ RawFormat ➤ Adobe PDF ➤ EPS To find out which options you must create a File object and then pass a reference to the object to alias "...
...Reference look up the Photo CD open options class or the EPS open objects class. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or the Adobe Photoshop CS4 JavaScript Scripting Reference, look up the PhotoCDOpenOptions or EPSOpenOptions objects. Specifying file formats to open Open Classes Open Options...document is opened, which page to open to in a multi-page file, etc. ➤ PhotoCD ➤ CameraRaw ➤ RawFormat ➤ Adobe PDF ➤ EPS To find out which options you must create a File object and then pass a reference to the object to alias "...
Scripting Guide
Page 30
...open the file app.open( fileRef, pdfOpenOptions ) // restore unit settings app.preferences.rulerUnits = originalRulerUnits tell application "Adobe Photoshop CS4" set myFilePath to alias "OS X 10.4.8 US:Users:psauto:Desktop:opal_screen.pdf" with timeout of 300 seconds ...RulerUnits appRef.Preferences.RulerUnits = 1 'value of 1 = psPixels 'Create a PDF option object Dim pdfOpenOptionsRef Set pdfOpenOptionsRef = CreateObject("Photoshop.PDFOpenOptions") pdfOpenOptionsRef.AntiAlias = True pdfOpenOptionsRef.Mode = 2 ' psOpenRGB pdfOpenOptionsRef.Resolution = 72 pdfOpenOptionsRef.Page = 3 ' open the ...
...open the file app.open( fileRef, pdfOpenOptions ) // restore unit settings app.preferences.rulerUnits = originalRulerUnits tell application "Adobe Photoshop CS4" set myFilePath to alias "OS X 10.4.8 US:Users:psauto:Desktop:opal_screen.pdf" with timeout of 300 seconds ...RulerUnits appRef.Preferences.RulerUnits = 1 'value of 1 = psPixels 'Create a PDF option object Dim pdfOpenOptionsRef Set pdfOpenOptionsRef = CreateObject("Photoshop.PDFOpenOptions") pdfOpenOptionsRef.AntiAlias = True pdfOpenOptionsRef.Mode = 2 ' psOpenRGB pdfOpenOptionsRef.Resolution = 72 pdfOpenOptionsRef.Page = 3 ' open the ...
Scripting Guide
Page 31
... 31 Saving a Document Options for saving an .eps file, do the following: ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up the class EPS save options. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Adobe Photoshop CS4 JavaScript Scripting Reference look up EPSSaveOptions. See "Specifying file formats to note that begins with...
... 31 Saving a Document Options for saving an .eps file, do the following: ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up the class EPS save options. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Adobe Photoshop CS4 JavaScript Scripting Reference look up EPSSaveOptions. See "Specifying file formats to note that begins with...
Scripting Guide
Page 32
... you can use properties of the settings class to view all of settings to pixel units In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up class settings-object to set application preferences such as color picker, file saving options...settings, and so on. VBS The Preferences object is a property of Photoshop. Additionally, look up the Preferences object to view all of the settings properties you display by choosing Photoshop > Preferences on Mac OS or Edit > Preferences in Windows versions of the Application object. ...
... you can use properties of the settings class to view all of settings to pixel units In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up class settings-object to set application preferences such as color picker, file saving options...settings, and so on. VBS The Preferences object is a property of Photoshop. Additionally, look up the Preferences object to view all of the settings properties you display by choosing Photoshop > Preferences on Mac OS or Edit > Preferences in Windows versions of the Application object. ...
Scripting Guide
Page 33
...VBS To set dialog preferences, you do not want dialogs to be sitting at the machine. In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Photoshop AppleScript Dictionary, look up the options for the display dialogs property. JS To set display dialogs to the... property. preferences.rulerUnits = Units.INCHES preferences.typeUnits = TypeUnits.PIXELS In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Class application to find the values you must ...
...VBS To set dialog preferences, you do not want dialogs to be sitting at the machine. In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Photoshop AppleScript Dictionary, look up the options for the display dialogs property. JS To set display dialogs to the... property. preferences.rulerUnits = Units.INCHES preferences.typeUnits = TypeUnits.PIXELS In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Class application to find the values you must ...
Scripting Guide
Page 35
...units of settings set ruler units of settings to inch units set duckFile to alias ¬ "OS X 10.4.8 US:Applications:Adobe Photoshop CS4:Samples:Ducky.tif" open duckFile set docRef to current document resize image docRef width 4 height 4 resize canvas docRef width 4 ...the top and bottom of the document window (or canvas) to pixels appRef.Preferences.RulerUnits = 1 ' (psPixels) CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit ...
...units of settings set ruler units of settings to inch units set duckFile to alias ¬ "OS X 10.4.8 US:Applications:Adobe Photoshop CS4:Samples:Ducky.tif" open duckFile set docRef to current document resize image docRef width 4 height 4 resize canvas docRef width 4 ...the top and bottom of the document window (or canvas) to pixels appRef.Preferences.RulerUnits = 1 ' (psPixels) CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit ...
Scripting Guide
Page 37
...a fill to the selection app.activeDocument.selection.selectAll // Create a color to be used with the fill command Dim colorObj Set colorObj = CreateObject("Photoshop.SolidColor") colorObj.RGB.Red = 255 colorObj.RGB.Green = 0 colorObj.RGB.Blue = 0 ' Now apply fill to the current selection appRef....green = 100 colorRef.rgb.blue = 0 // Now apply fill to the current selection app.activeDocument.selection.fill(colorRef) tell application "Adobe Photoshop CS4" make new document make new art layer at beginning of current document ¬ with properties {name:"MyBlendLayer", blend mode:normal} select ...
...a fill to the selection app.activeDocument.selection.selectAll // Create a color to be used with the fill command Dim colorObj Set colorObj = CreateObject("Photoshop.SolidColor") colorObj.RGB.Red = 255 colorObj.RGB.Green = 0 colorObj.RGB.Blue = 0 ' Now apply fill to the current selection appRef....green = 100 colorRef.rgb.blue = 0 // Now apply fill to the current selection app.activeDocument.selection.fill(colorRef) tell application "Adobe Photoshop CS4" make new document make new art layer at beginning of current document ¬ with properties {name:"MyBlendLayer", blend mode:normal} select ...