Scripting Guide
Page 6
...using the Extend Script Object Model Viewer, see the JavaScript Tools Guide. See "Viewing Photoshop's AppleScript dictionary" on page 21 and "Viewing Photoshop's type library (VBS)" on Mac OS® and Windows®. Conventions in this Guide Code and specific language samples...object browsers available for scripting the Photoshop application. 1 Introduction About this Manual This manual provides an introduction to execute scripts, and the Photoshop object model. Chapter 2 covers a brief overview of scripting, how to scripting Adobe® Photoshop® CS4 on page 22. For information ...
...using the Extend Script Object Model Viewer, see the JavaScript Tools Guide. See "Viewing Photoshop's AppleScript dictionary" on page 21 and "Viewing Photoshop's type library (VBS)" on Mac OS® and Windows®. Conventions in this Guide Code and specific language samples...object browsers available for scripting the Photoshop application. 1 Introduction About this Manual This manual provides an introduction to execute scripts, and the Photoshop object model. Chapter 2 covers a brief overview of scripting, how to scripting Adobe® Photoshop® CS4 on page 22. For information ...
Scripting Guide
Page 8
...; For examples of scripts created specifically for the scripting languages AppleScript, VBScript, and JavaScript, how 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. Why use the reference information in the Introduction to do the following list to locate information that is...
...; For examples of scripts created specifically for the scripting languages AppleScript, VBScript, and JavaScript, how 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. Why use the reference information in the Introduction to do the following list to locate information that is...
Scripting Guide
Page 10
... Scripts added to execute scripts that it finds in this main startup folder, it is : C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for execution. By putting a JavaScript file into the appropriate location on disk, it must include... code such as an installed script. Executing other Adobe Creative Suite 3 applications at the end of sub-folders does not add...
... Scripts added to execute scripts that it finds in this main startup folder, it is : C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for execution. By putting a JavaScript file into the appropriate location on disk, it must include... code such as an installed script. Executing other Adobe Creative Suite 3 applications at the end of sub-folders does not add...
Scripting Guide
Page 16
... constant is PSLayerKind, for commands or methods. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. The value type for the property. For general information about... information about constants, see Introduction to the right of the Application object. 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.
... constant is PSLayerKind, for commands or methods. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. The value type for the property. For general information about... information about constants, see Introduction to the right of the Application object. 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.
Scripting Guide
Page 18
...of text object of artLayerRef to make new art layer in docRef -- set its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- Get a reference to Scripting, which has a section on AppleScript debugging. Photoshop creates a new document, adds a new layer, changes the layer's type to text and sets... kind of artLayerRef to be a text layer. NOTE: The default location for the Script Editor is optional. -- CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 18 Creating and running an AppleScript You must open the Apple® Script Editor ...
...of text object of artLayerRef to make new art layer in docRef -- set its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- Get a reference to Scripting, which has a section on AppleScript debugging. Photoshop creates a new document, adds a new layer, changes the layer's type to text and sets... kind of artLayerRef to be a text layer. NOTE: The default location for the Script Editor is optional. -- CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 18 Creating and running an AppleScript You must open the Apple® Script Editor ...
Scripting Guide
Page 20
... the following script. The scripts do not appear on the File > Scripts menu until you restart the application. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory. var textItemRef = artLayerRef.textItem textItemRef.contents = "Hello, World" // Release references docRef = null artLayerRef = null textItemRef = null // Restore...
... the following script. The scripts do not appear on the File > Scripts menu until you restart the application. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory. var textItemRef = artLayerRef.textItem textItemRef.contents = "Hello, World" // Release references docRef = null artLayerRef = null textItemRef = null // Restore...
Scripting Guide
Page 21
... elements used in the script. See the JavaScript Tools Guide for each command. 21 Viewing Photoshop's AppleScript dictionary You use the ExtendScript Object Model Viewer. Choose Adobe Photoshop CS4, and then click Open. Script Editor opens Photoshop and then displays the Photoshop dictionary, which lists objects as well as the commands, properties and elements associated with...
... elements used in the script. See the JavaScript Tools Guide for each command. 21 Viewing Photoshop's AppleScript dictionary You use the ExtendScript Object Model Viewer. Choose Adobe Photoshop CS4, and then click Open. Script Editor opens Photoshop and then displays the Photoshop dictionary, which lists objects as well as the commands, properties and elements associated with...
Scripting Guide
Page 22
... do not need to display more information abut the class. Click on page 19.) On the COM tab, find "Adobe Photoshop CS4 Object Library". Click OK. 7. Viewing Photoshop's type library (VBS) You can select one to target the Application object because you run your AppleScript and VBScript scripts... list of the window. 6. The objects defined in Microsoft Word: 1. To view the VBS object library in the Photoshop library are listed. Choose Photoshop CS4 type library from outside the Photoshop application, the first thing your script should do is loaded into the object browser.
... do not need to display more information abut the class. Click on page 19.) On the COM tab, find "Adobe Photoshop CS4 Object Library". Click OK. 7. Viewing Photoshop's type library (VBS) You can select one to target the Application object because you run your AppleScript and VBScript scripts... list of the window. 6. The objects defined in Microsoft Word: 1. To view the VBS object library in the Photoshop library are listed. Choose Photoshop CS4 type library from outside the Photoshop application, the first thing your script should do is loaded into the object browser.
Scripting Guide
Page 23
... type of object you want to create and then use the following statements: tell application "Adobe Photoshop CS4" ... CHAPTER 3: Scripting Photoshop Creating New Objects in a Script 23 AS To target Photoshop in AppleScript, you add an art layer to the art layers collection. end tell NOTE:... Preferences objects. To create an object in a script. The following to target the application: Dim appRef Set appRef = CreateObject("Photoshop.Application") JS In JavaScript, because you to reference the Application object throughout the script. See Introduction to Scripting for you do ...
... type of object you want to create and then use the following statements: tell application "Adobe Photoshop CS4" ... CHAPTER 3: Scripting Photoshop Creating New Objects in a Script 23 AS To target Photoshop in AppleScript, you add an art layer to the art layers collection. end tell NOTE:... Preferences objects. To create an object in a script. The following to target the application: Dim appRef Set appRef = CreateObject("Photoshop.Application") JS In JavaScript, because you to reference the Application object throughout the script. See Introduction to Scripting for you do ...
Scripting Guide
Page 24
... dictionary" on page 22 for more about creating objects in an AppleScript: ➤ Look up the object in the Adobe Photoshop CS4 AppleScript Scripting Reference. VBS In VBScript, you must use the collection name, which commands can use the Add method only ...VBScript or JavaScript object to an element the same way you cannot use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in your script. appRef.Documents(1).ArtLayers.Add() NOTE: In Photoshop, VBScript collections index from 1 rather than index 0. make new document You can also use the object...
... dictionary" on page 22 for more about creating objects in an AppleScript: ➤ Look up the object in the Adobe Photoshop CS4 AppleScript Scripting Reference. VBS In VBScript, you must use the collection name, which commands can use the Add method only ...VBScript or JavaScript object to an element the same way you cannot use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in your script. appRef.Documents(1).ArtLayers.Add() NOTE: In Photoshop, VBScript collections index from 1 rather than index 0. make new document You can also use the object...
Scripting Guide
Page 25
...of Document. Similarly, the ArtLayer object does not have an add() method; For more information, look up the Layers object in the Adobe Photoshop CS4 Visual Basic Scripting Reference. For example, to work on the active document. Setting the Active Object To work in a layer, you... objects, which are acting on either the ArtLayers or LayerSets collections. CHAPTER 3: Scripting Photoshop Setting the Active Object 25 If you look up in the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Visual Basic Object Browser, you will see that...
...of Document. Similarly, the ArtLayer object does not have an add() method; For more information, look up the Layers object in the Adobe Photoshop CS4 Visual Basic Scripting Reference. For example, to work on the active document. Setting the Active Object To work in a layer, you... objects, which are acting on either the ArtLayers or LayerSets collections. CHAPTER 3: Scripting Photoshop Setting the Active Object 25 If you look up in the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Visual Basic Object Browser, you will see that...
Scripting Guide
Page 26
...docRef --here you will find it has the property of current, and so on. Similarly, if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you find activeLayer and activeHistoryState as properties. Then, you could 'make ... property of the application class to --bring otherDocRef front-most as the new active document Set app.ActiveDocument = otherDocRef CHAPTER 3: Scripting Photoshop Setting the Active Object 26 NOTE: The parent object is the object that perform actions on the active document. a document is the...
...docRef --here you will find it has the property of current, and so on. Similarly, if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you find activeLayer and activeHistoryState as properties. Then, you could 'make ... property of the application class to --bring otherDocRef front-most as the new active document Set app.ActiveDocument = otherDocRef CHAPTER 3: Scripting Photoshop Setting the Active Object 26 NOTE: The parent object is the object that perform actions on the active document. a document is the...
Scripting Guide
Page 27
...activeDocument = docRef docRef.activeLayer = docRef.layers[0] Look up the ActiveLayer property on the Document object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser. NOTE: You can also use the name of current document...docRef.ActiveLayer = docRef.Layers(1) Look up the activeLayer property on the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer. By default, Photoshop names the layers "Layer 1", "Layer2". See "Referencing ArtLayer objects" on page 38. ...
...activeDocument = docRef docRef.activeLayer = docRef.layers[0] Look up the ActiveLayer property on the Document object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser. NOTE: You can also use the name of current document...docRef.ActiveLayer = docRef.Layers(1) Look up the activeLayer property on the Document object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer. By default, Photoshop names the layers "Layer 1", "Layer2". See "Referencing ArtLayer objects" on page 38. ...
Scripting Guide
Page 29
... opened, which page to open to in a multi-page file, etc. ➤ PhotoCD ➤ CameraRaw ➤ RawFormat ➤ Adobe PDF ➤ EPS To find out which options you can set for each of images in JavaScript, you can set options to specify...file format name. For example: ➤ In the Adobe Photoshop CS4 AppleScript Scripting 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 ...
... opened, which page to open to in a multi-page file, etc. ➤ PhotoCD ➤ CameraRaw ➤ RawFormat ➤ Adobe PDF ➤ EPS To find out which options you can set for each of images in JavaScript, you can set options to specify...file format name. For example: ➤ In the Adobe Photoshop CS4 AppleScript Scripting 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 ...
Scripting Guide
Page 30
...twice as wide as PDF with timeout 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... 1 'value of 300 seconds 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 options ¬ {class:PDF open ...
...twice as wide as PDF with timeout 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... 1 'value of 300 seconds 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 options ¬ {class:PDF open ...
Scripting Guide
Page 31
...for comparison. CHAPTER 3: Scripting Photoshop Saving a Document 31 Saving a Document Options for saving an .eps file, do the following scripts save options. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Adobe Photoshop CS4 JavaScript Scripting Reference look up ...Wavefront RLA ➤ SoftImage The following : ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up the class EPS save a document as JPEG with the file format name. AS tell application "Adobe Photoshop CS4" make new document set myFile to "OS X 10.4.8 US:...
...for comparison. CHAPTER 3: Scripting Photoshop Saving a Document 31 Saving a Document Options for saving an .eps file, do the following scripts save options. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference or in the Adobe Photoshop CS4 JavaScript Scripting Reference look up ...Wavefront RLA ➤ SoftImage The following : ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up the class EPS save a document as JPEG with the file format name. AS tell application "Adobe Photoshop CS4" make new document set myFile to "OS X 10.4.8 US:...
Scripting Guide
Page 32
... to the Photoshop CS4 Preferences dialog options, which you can use . Additionally, look up the Preferences property on Mac OS or Edit > Preferences in the settings class/Preferences object correlate to Photoshop Help. CHAPTER 3: Scripting Photoshop Setting Application Preferences...PsTypeUnits --> 1 (psPixels) In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up the Preferences object to pixel units In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up class settings-...
... to the Photoshop CS4 Preferences dialog options, which you can use . Additionally, look up the Preferences property on Mac OS or Edit > Preferences in the settings class/Preferences object correlate to Photoshop Help. CHAPTER 3: Scripting Photoshop Setting Application Preferences...PsTypeUnits --> 1 (psPixels) In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser, look up the Preferences object to pixel units In the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the Photoshop AppleScript Dictionary, look up class settings-...
Scripting Guide
Page 33
...get to be sitting at the machine. If a dialog appears, your script. For information on the Application object. In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property displayDialogs, and then look ...up the preferences property on object models, see the value type for PsDialogModes. displayDialogs = DialogModes.NO In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser, look up the Class application to view all of the Application ...
...get to be sitting at the machine. If a dialog appears, your script. For information on the Application object. In the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property displayDialogs, and then look ...up the preferences property on object models, see the value type for PsDialogModes. displayDialogs = DialogModes.NO In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser, look up the Class application to view all of the Application ...
Scripting Guide
Page 35
...inches wide. ➤ Trim the top and bottom 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 ruler units of the image. ➤ Crop the image. ➤ Flip the entire window. ➤ ...Restore the original ruler units. AS tell application "Adobe Photoshop CS4" set saveUnit to ruler units of settings set docRef to current document resize image docRef width 4 height 4 resize canvas docRef width 4 height ...
...inches wide. ➤ Trim the top and bottom 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 ruler units of the image. ➤ Crop the image. ➤ Flip the entire window. ➤ ...Restore the original ruler units. AS tell application "Adobe Photoshop CS4" set saveUnit to ruler units of settings set docRef to current document resize image docRef width 4 height 4 resize canvas docRef width 4 height ...
Scripting Guide
Page 37
tell application "Adobe Photoshop CS4" make new document make a new document app.documents.add() ... // Create a color to the current selection app.activeDocument.selection.fill(colorRef) CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 37 Creating an ArtLayer object AS VBS JS The following examples demonstrate how to create... appRef.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...
tell application "Adobe Photoshop CS4" make new document make a new document app.documents.add() ... // Create a color to the current selection app.activeDocument.selection.fill(colorRef) CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 37 Creating an ArtLayer object AS VBS JS The following examples demonstrate how to create... appRef.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...