Adobe 65048332 Scripting Guide - Page 34

Using the Application object, Using the Document object, Photoshop Object Model

Page 34 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 34 Using the Application object This section describes how and when to use the Application object in a script. It also describes how to use some properties of the Application object. You use the properties and commands of the Application object to work with Photoshop functionality and objects such as the following: ➤ Global Photoshop settings or preferences, such as unit values or color settings - See "Setting Application Preferences" on page 32. ➤ Documents - You can add or open documents and set the active document. "Opening a Document" on page 28 and "Setting the Active Object" on page 25. ➤ Actions - You can execute actions created either via scripting or using the Actions palette in the Photoshop application. See "Action Manager" on page 73. You can use Application object properties to get information such as the following: ➤ A list of fonts installed on the system. ➣ AS: set theFonts to fonts NOTE: In AppleScript, fonts is a separate collection, and does not require a reference to the application object to retrieve it. ➣ VBS: Set fontsInstalled = AppRef.Fonts ➣ JS: var fontsInstalled = app.fonts ➤ The amount of unused memory available to Adobe Photoshop, using the free memory (FreeMemory/freeMemory) property of the Application object. ➤ The location of the Preferences folder, using the preferences folder (PreferencesFolder/preferencesFolder) property of the Application object. For further information, look up the properties of the Application object in the reference manual or the object browser of the language you are using. Using the Document object The Document object can represent any open document in Photoshop. You can think of a Document object as a file; you can also think of it as a canvas. You work with the Document object to do the following: ➤ Access script objects contained in the Document object, such as ArtLayer or Channel objects. See "Photoshop Object Model" on page 11 for more information. ➤ Manipulate a specific Document object, using commands or methods. For example, you could crop, rotate or flip the canvas, resize the image or canvas, and trim the image. See "Manipulating a document object" on page 35 for a demonstration. ➤ Get the active layer. See "Setting the active layer" on page 27. ➤ Save the current document. See "Saving a Document" on page 31. ➤ Copy and paste within the active document or between different documents. See "Understanding Clipboard Interaction" on page 54.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87

C
HAPTER
3: Scripting Photoshop
Working with the Photoshop Object Model
34
Using the Application object
This section describes how and when to use the
Application
object in a script. It also describes how to
use some properties of the
Application
object.
You use the properties and commands of the
Application
object to work with Photoshop functionality
and objects such as the following:
Global Photoshop settings or preferences, such as unit values or color settings
— See
“Setting
Application Preferences” on page 32
.
Documents
— You can add or open documents and set the active document.
“Opening a Document”
on page 28
and
“Setting the Active Object” on page 25
.
Actions
— You can execute actions created either via scripting or using the Actions palette in the
Photoshop application. See
“Action Manager” on page 73
.
You can use
Application
object properties to get information such as the following:
A list of fonts installed on the system.
AS: set
theFonts
to
fonts
N
OTE
:
In AppleScript, fonts is a separate collection, and does not require a reference to the
application object to retrieve it.
VBS: Set
fontsInstalled
=
AppRef.Fonts
JS:
var
fontsInstalled
=
app.fonts
The amount of unused memory available to Adobe Photoshop, using the
free
memory
(FreeMemory/freeMemory)
property of the
Application
object.
The location of the Preferences folder, using the
preferences
folder
(PreferencesFolder/preferencesFolder)
property of the
Application
object.
For further information, look up the properties of the
Application
object in the reference manual or the
object browser of the language you are using.
Using the Document object
The
Document
object can represent any open document in Photoshop. You can think of a
Document
object
as a file; you can also think of it as a canvas. You work with the
Document
object to do the following:
Access script objects contained in the
Document
object, such as
ArtLayer
or
Channel
objects. See
“Photoshop Object Model” on page 11
for more information.
Manipulate a specific
Document
object, using commands or methods. For example, you could crop,
rotate or flip the canvas, resize the image or canvas, and trim the image. See
“Manipulating a
document object” on page 35
for a demonstration.
Get the active layer. See
“Setting the active layer” on page 27
.
Save the current document. See
“Saving a Document” on page 31
.
Copy and paste within the active document or between different documents. See
“Understanding
Clipboard Interaction” on page 54
.