Adobe 23102480 Scripting Guide - Page 32

Using the Document Object, Manipulating a Document Object

Page 32 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 32 You use the properties and commands of the Application object to work with Photoshop CS3 functionality and objects such as the following: ● Global Photoshop CS3 settings or preferences, such as unit values or color settings. See 'Setting Application Preferences' on page 30. ● Documents-You can add or open documents and set the active document. 'Opening a Document' on page 26 and 'Setting the Active Object' on page 23. ● Actions-You can execute actions created either via scripting or using the Actions palette in the Photoshop CS3 application. See 'Action Manager' on page 72. 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 CS3, 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 CS3. 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 CS3 Object Model' on page 9 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 32 for a demonstration. ● Get the active layer. See 'Setting the Active Layer' on page 25. ● Save the current document. See 'Saving a Document' on page 29. ● Copy and paste within the active document or between different documents. See 'Understanding Clipboard Interaction' on page 54. Manipulating a Document Object The following examples demonstrate how to do the following: ● Save the existing ruler unit preferences, and set ruler units to inches ● Open an existing file as a document (using file Ducky.tif ) ● Change the size of the image to 4 inches wide and 4 inches high. ● Change the size of the document window (or canvas) to 4 inches high and 4 inches wide. ● Trim the top and bottom of the image.

  • 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

Photoshop CS3
Adobe Photoshop CS3
Scripting Guide
Scripting Photoshop CS3
32
You use the properties and commands of the
Application
object to work with Photoshop CS3
functionality and objects such as the following:
Global Photoshop CS3 settings or preferences, such as unit values or color settings. See
‘Setting
Application Preferences’ on page 30
.
Documents—You can add or open documents and set the active document.
‘Opening a Document’ on
page 26
and
‘Setting the Active Object’ on page 23
.
Actions—You can execute actions created either via scripting or using the Actions palette in the
Photoshop CS3 application. See
‘Action Manager’ on page 72
.
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 CS3, 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 CS3. 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 CS3 Object Model’ on page 9
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 32
for a demonstration.
Get the active layer. See
‘Setting the Active Layer’ on page 25
.
Save the current document. See
‘Saving a Document’ on page 29
.
Copy and paste within the active document or between different documents. See
‘Understanding
Clipboard Interaction’ on page 54
.
Manipulating a Document Object
The following examples demonstrate how to do the following:
Save the existing ruler unit preferences, and set ruler units to inches
Open an existing file as a document (using file Ducky.tif)
Change the size of the image to 4 inches wide and 4 inches high.
Change the size of the document window (or canvas) to 4 inches high and 4 inches wide.
Trim the top and bottom of the image.