Scripting Guide
Page 6
... shipped with this manual follows the AppleScript naming convention for late-breaking news, sample scripts, and information about using the Extend Script Object Model Viewer, see the JavaScript Tools Guide. Code examples are used when referring to AppleScript, VBScript and JavaScript. ... of these languages through the Scripting Reference Manuals provided with Photoshop for that is provided for each language. Chapter 1 covers the basic conventions used to refer both to scripting Adobe® Photoshop® CS4 on page 22. Conventions in this Guide Code and specific...
... shipped with this manual follows the AppleScript naming convention for late-breaking news, sample scripts, and information about using the Extend Script Object Model Viewer, see the JavaScript Tools Guide. Code examples are used when referring to AppleScript, VBScript and JavaScript. ... of these languages through the Scripting Reference Manuals provided with Photoshop for that is provided for each language. Chapter 1 covers the basic conventions used to refer both to scripting Adobe® Photoshop® CS4 on page 22. Conventions in this Guide Code and specific...
Scripting Guide
Page 8
...border to add depending on page 21. See "Viewing Photoshop Objects, Commands, and Methods" on 8 Scripts automate repetitive tasks and are often used Photoshop Actions, you to extend those benefits by a collection of the three scripting ...series 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 with the enormous benefits of actions? Scripting allows you 're already familiar with Photoshop, see Chapter 3, "Scripting Photoshop" on page 21. ...
...border to add depending on page 21. See "Viewing Photoshop Objects, Commands, and Methods" on 8 Scripts automate repetitive tasks and are often used Photoshop Actions, you to extend those benefits by a collection of the three scripting ...series 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 with the enormous benefits of actions? Scripting allows you 're already familiar with Photoshop, see Chapter 3, "Scripting Photoshop" on page 21. ...
Scripting Guide
Page 10
... in the 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. Scripts added to select scripts installed in the browse dialog. You...sub-folders does not add a hierarchical organization to select a script file for user-defined scripts is: ~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop If your JavaScripts. The addition of scripts may be accessed from AS or VBS You can be installed in the Scripts ...
... in the 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. Scripts added to select scripts installed in the browse dialog. You...sub-folders does not add a hierarchical organization to select a script file for user-defined scripts is: ~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop If your JavaScripts. The addition of scripts may be accessed from AS or VBS You can be installed in the Scripts ...
Scripting Guide
Page 16
...contains a link to define the kind property. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. Constants are constants. For more information about constants, see ...value type for the Art Layer object's kind property. 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 "Opening a Document" on page ...
...contains a link to define the kind property. For example, look up the art ArtLayer object in either the Adobe Photoshop CS4 JavaScript Scripting Reference or in the containment hierarchy above. Constants are constants. For more information about constants, see ...value type for the Art Layer object's kind property. 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 "Opening a Document" on page ...
Scripting Guide
Page 18
...object of artLayerRef to be a text layer. Enter the following script in order to complete this procedure. set its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- Get a reference to make new document with properties ¬ {width:4 as inches, height:2 as inches} set artLayerRef ..., which has a section on AppleScript debugging. Create a new document and art layer. Entering the comments is Applications > AppleScript > Script Editor. Photoshop creates a new document, adds a new layer, changes the layer's type to text and sets the text to "Hello, World" NOTE: If...
...object of artLayerRef to be a text layer. Enter the following script in order to complete this procedure. set its contents. --target Photoshop CS4 tell application "Adobe Photoshop CS4" -- Get a reference to make new document with properties ¬ {width:4 as inches, height:2 as inches} set artLayerRef ..., which has a section on AppleScript debugging. Create a new document and art layer. Entering the comments is Applications > AppleScript > Script Editor. Photoshop creates a new document, adds a new layer, changes the layer's type to text and sets the text to "Hello, World" NOTE: If...
Scripting Guide
Page 20
... then choose File > Scripts, and then select your script from the File > Scripts menu in your first Photoshop JavaScript: 1. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory. Do either of the text layer. var textItemRef = artLayerRef.textItem textItemRef.contents = "Hello, World" // Release references docRef...
... then choose File > Scripts, and then select your script from the File > Scripts menu in your first Photoshop JavaScript: 1. CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 20 To create and run your Adobe Photoshop CS4 directory. Do either of the text layer. var textItemRef = artLayerRef.textItem textItemRef.contents = "Hello, World" // Release references docRef...
Scripting Guide
Page 21
... about the objects, classes, properties, commands, and even some values (called constants or enumerations) you quickly understand how to script Photoshop. TIP: Throughout 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 use to create AppleScripts, VBScript scripts, and JavaScripts for...
... about the objects, classes, properties, commands, and even some values (called constants or enumerations) you quickly understand how to script Photoshop. TIP: Throughout 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 use to create AppleScripts, VBScript scripts, and JavaScripts for...
Scripting Guide
Page 22
... display more information about the class. On the COM tab, find "Adobe Photoshop CS4 Object Library". CHAPTER 3: Scripting Photoshop Targeting and Referencing the Application Object 22 NOTE: The Photoshop AppleScript Dictionary does not display the complete list of the window. 6. Choose Photoshop CS4 type library from the Photoshop application itself. (See "Creating and running a JavaScript" on the plus...
... display more information about the class. On the COM tab, find "Adobe Photoshop CS4 Object Library". CHAPTER 3: Scripting Photoshop Targeting and Referencing the Application Object 22 NOTE: The Photoshop AppleScript Dictionary does not display the complete list of the window. 6. Choose Photoshop CS4 type library from the Photoshop application itself. (See "Creating and running a JavaScript" on the plus...
Scripting Guide
Page 23
...document, such as part of object you want to create and then use the object's collection name to accomplish these same tasks in the Photoshop application, you select File > New. end tell NOTE: Because you include all commands in the tell block, there is not possible to...the art layers collection. The following to add a new Preferences object.) NOTE: In VBScript and JavaScript, you use the following statements: tell application "Adobe Photoshop CS4" ... To create an object in a script, you name the type of the containment hierarchy or leave it out, whichever makes your script in ...
...document, such as part of object you want to create and then use the object's collection name to accomplish these same tasks in the Photoshop application, you select File > New. end tell NOTE: Because you include all commands in the tell block, there is not possible to...the art layers collection. The following to add a new Preferences object.) NOTE: In VBScript and JavaScript, you use the following statements: tell application "Adobe Photoshop CS4" ... To create an object in a script, you name the type of the containment hierarchy or leave it out, whichever makes your script in ...
Scripting Guide
Page 24
...To create an object other than the documents name. To add an ArtLayer object, you cannot use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in a VBScript script, you must reference the Document object that will be used with the collection name.... in a Script 24 AS The following statement creates a Document object in the variable named docRef. make new document in the Adobe Photoshop CS4 AppleScript Scripting Reference. If an object has valid commands, there will contain the art layer. See "Targeting and Referencing the Application...
...To create an object other than the documents name. To add an ArtLayer object, you cannot use the set commands in the Adobe Photoshop CS4 AppleScript Scripting Reference or in a VBScript script, you must reference the Document object that will be used with the collection name.... in a Script 24 AS The following statement creates a Document object in the variable named docRef. make new document in the Adobe Photoshop CS4 AppleScript Scripting Reference. If an object has valid commands, there will contain the art layer. See "Targeting and Referencing the Application...
Scripting Guide
Page 25
...Add() method; For more information, look up the Layers object in the Adobe Photoshop CS4 Visual Basic Scripting Reference. If your script creates two or more information, look up the Layers object in the Adobe Photoshop CS4 JavaScript Scripting Reference. To set an active object, do the following statement ... to ensure that your script are created with the Document object. 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 ...
...Add() method; For more information, look up the Layers object in the Adobe Photoshop CS4 Visual Basic Scripting Reference. If your script creates two or more information, look up the Layers object in the Adobe Photoshop CS4 JavaScript Scripting Reference. To set an active object, do the following statement ... to ensure that your script are created with the Document object. 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 ...
Scripting Guide
Page 26
...new document with properties ¬ {width:4 as inches, height:6 as properties. For example, if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you would include command statements --that perform actions on . a document is... "Setting the active channels" on the active document. if you look at the Application object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Photoshop AppleScript Dictionary, you will find one of its properties is the parent of the document; Similarly, if ...
...new document with properties ¬ {width:4 as inches, height:6 as properties. For example, if you look at application in the Adobe Photoshop CS4 AppleScript Scripting Reference, or in the ExtendScript Object Model Viewer, you would include command statements --that perform actions on . a document is... "Setting the active channels" on the active document. if you look at the Application object in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Photoshop AppleScript Dictionary, you will find one of its properties is the parent of the document; Similarly, if ...
Scripting Guide
Page 27
... 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. In order to set the active layer. appRef.ActiveDocument = docRef... = 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". AS set current layer of current document ...
... 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. In order to set the active layer. appRef.ActiveDocument = docRef... = 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". AS set current layer of current document ...
Scripting Guide
Page 29
... types on the following specifications: ➤ The document will open in RGB mode with the file format name. CHAPTER 3: Scripting Photoshop Opening a Document 29 AS set theFile to alias "Applications:Documents:MyFile" open theFile VBS fileName = "C:\MyFile" Set docRef = .... 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...
... types on the following specifications: ➤ The document will open in RGB mode with the file format name. CHAPTER 3: Scripting Photoshop Opening a Document 29 AS set theFile to alias "Applications:Documents:MyFile" open theFile VBS fileName = "C:\MyFile" Set docRef = .... 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...
Scripting Guide
Page 30
... not 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 file ...= appRef.Preferences.RulerUnits appRef.Preferences.RulerUnits = 1 'value of 300 seconds open myFilePath as it is tall. 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 ...
... not 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 file ...= appRef.Preferences.RulerUnits appRef.Preferences.RulerUnits = 1 'value of 300 seconds open myFilePath as it is tall. 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
... open" on page 29 for a specific file format save option, look up the class EPS save current document in the Adobe Photoshop CS4 JavaScript Scripting Reference look up the object that the Open and Save formats are not identical. See "Specifying file formats to ... about properties for saving an .eps file, do the following optional formats are illustrated below. NOTE: The following : ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up EPSSaveOptions. For example, to ¬ {class:JPEG save options, embed color profile:false, ¬ format options...
... open" on page 29 for a specific file format save option, look up the class EPS save current document in the Adobe Photoshop CS4 JavaScript Scripting Reference look up the object that the Open and Save formats are not identical. See "Specifying file formats to ... about properties for saving an .eps file, do the following optional formats are illustrated below. NOTE: The following : ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference, look up EPSSaveOptions. For example, to ¬ {class:JPEG save options, embed color profile:false, ¬ format options...
Scripting Guide
Page 32
... units of settings to inch units set type units 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 view all of the settings properties you can... = 1 'for psNoMatte jpgSaveOptions.Quality = 1 appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _ jpgSaveOptions, True, 2 'for 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 view all of the settings properties you must...
... units of settings to inch units set type units 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 view all of the settings properties you can... = 1 'for psNoMatte jpgSaveOptions.Quality = 1 appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _ jpgSaveOptions, True, 2 'for 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 view all of the settings properties you must...
Scripting Guide
Page 33
... the display dialogs property. You can also look up the Application object property DisplayDialogs. displayDialogs = DialogModes.NO In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property displayDialogs, and then look... user to be able to control dialogs properly from being displayed: set display dialogs to never In the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the constant DialogModes. If a dialog appears, your script is important to be...
... the display dialogs property. You can also look up the Application object property DisplayDialogs. displayDialogs = DialogModes.NO In the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer, look up the Application object property displayDialogs, and then look... user to be able to control dialogs properly from being displayed: set display dialogs to never In the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the constant DialogModes. If a dialog appears, your script is important to be...
Scripting Guide
Page 35
... 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...2 (psInches) Set docRef = appRef.Open(appRef.Path & "\Samples\Ducky.tif") docRef.ResizeImage 4,4 docRef.ResizeCanvas 4,4 'Trim the document with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit preferences, and ...
... 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...2 (psInches) Set docRef = appRef.Open(appRef.Path & "\Samples\Ducky.tif") docRef.ResizeImage 4,4 docRef.ResizeCanvas 4,4 'Trim the document with the Photoshop Object Model 35 Manipulating a document object The following examples demonstrate how to do the following: ➤ Save the existing ruler unit preferences, and ...
Scripting Guide
Page 37
...rgb.green = 100 colorRef.rgb.blue = 0 // Now apply fill 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....to the selection app.activeDocument.selection.selectAll // Create a color 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...
...rgb.green = 100 colorRef.rgb.blue = 0 // Now apply fill 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....to the selection app.activeDocument.selection.selectAll // Create a color 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...