Adobe 65014293 Scripting Guide - Page 47

Using the Document Info object, Using history state objects, File > File Info, Window > History

Page 47 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 47 AS VBS JS set kind of myChannel to selected area channel channelRef.ind = 3 'for psSelectedAreaAlphaChannel 'from the constant value PsChannelType channelRef.kind = ChannelType.SELECTEDAREA Using the Document Info object In Photoshop, you can associate information with a document by choosing File > File Info. To accomplish this task in a script, you use the info-object (DocumentInfo/DocumentInfo) object, which is stored in the info (Info/info) property of the Document object. The following examples demonstrate how to use the DocumentInfo object to set the copyrighted status and owner URL of a document. AS VBS JS set docInfoRef to info of current document get EXIF of docInfoRef set copyrighted of docInfoRef to copyrighted work set owner url of docInfoRef to "http://www.adobe.com" get EXIF of docInfoRef Set docInfoRef = docRef.Info docInfoRef.Copyrighted = 1 'for psCopyrightedWork docInfoRef.OwnerUrl = "http://www.adobe.com" docInfoRef = docRef.info docInfoRef.copyrighted = CopyrightedType.COPYRIGHTEDWORK docInfoRef.ownerUrl = "http://www.adobe.com" For information about other types of information (properties) you can associate with a document, look up the following: ➤ In the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary, look up the properties for the class info-object. ➤ In the Adobe Photoshop CS4 Visual Basic Scripting Reference, the Adobe Photoshop CS4 JavaScript Scripting Reference, the Visual Basic Object Browser or the ExtendScript Object Model Viewer, look up the properties for the DocumentInfo object. Using history state objects Photoshop keeps a history of the actions that affect documents. Each time you apply a change to an image in the Photoshop application, you create a history state; you can access a document's history states from the History palette by selecting Window > History. See Photoshop Help for additional information about History State. In a script, you can access a Document object's history states using the HistoryStates object, which is a property of the Document object. You can use a HistoryStates object to reset a document to a previous state or to fill a Selection object. The following examples revert the document contained in the variable docRef back to the form and properties it had when it was first opened or created. Using history states in this fashion gives you the ability to undo modifications to the document.

  • 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
47
AS
set kind of myChannel to selected area channel
VBS
channelRef.ind = 3 'for psSelectedAreaAlphaChannel
'from the constant value PsChannelType
JS
channelRef.kind = ChannelType.SELECTEDAREA
Using the Document Info object
In Photoshop, you can associate information with a document by choosing
File > File Info
.
To accomplish this task in a script, you use the
info-object
(
DocumentInfo/DocumentInfo)
object,
which is stored in the
info
(
Info
/
info
) property of the
Document
object. The following examples
demonstrate how to use the
DocumentInfo
object to set the copyrighted status and owner URL of a
document.
AS
set docInfoRef to info of current document
get EXIF of docInfoRef
set copyrighted of docInfoRef to copyrighted work
set owner url of docInfoRef to "http://www.adobe.com"
get EXIF of docInfoRef
VBS
Set docInfoRef = docRef.Info
docInfoRef.Copyrighted = 1 'for psCopyrightedWork
docInfoRef.OwnerUrl = "http://www.adobe.com"
JS
docInfoRef = docRef.info
docInfoRef.copyrighted = CopyrightedType.COPYRIGHTEDWORK
docInfoRef.ownerUrl = "http://www.adobe.com"
For information about other types of information (properties) you can associate with a document, look up
the following:
In the
Adobe Photoshop CS4 AppleScript Scripting Reference
or in the Photoshop AppleScript Dictionary,
look up the properties for the class
info-object
.
In the
Adobe Photoshop CS4 Visual Basic Scripting Reference
, the
Adobe Photoshop CS4 JavaScript
Scripting Reference
, the Visual Basic Object Browser or the ExtendScript Object Model Viewer, look up
the properties for the
DocumentInfo
object.
Using history state objects
Photoshop keeps a history of the actions that affect documents. Each time you apply a change to an image
in the Photoshop application, you create a
history state
; you can access a document’s history states from
the History palette by selecting
Window > History
. See Photoshop Help for additional information about
History State.
In a script, you can access a
Document
object’s history states using the
HistoryStates
object, which is a
property of the
Document
object. You can use a
HistoryStates
object to reset a document to a previous
state or to fill a
Selection
object.
The following examples revert the document contained in the variable
docRef
back to the form and
properties it had when it was first opened or created. Using history states in this fashion gives you the
ability to undo modifications to the document.