Adobe 65015634 Scripting Guide - Page 28

Setting the active channels, Opening a Document, Opening a file with default file format

Page 28 highlights

CHAPTER 3: Scripting Photoshop Opening a Document 28 Setting the active channels More than one channel can be active at a time, so the current channels (ActiveChannels/activeChannels) property of the Document object takes an array of channels as a value. In order to set the active channels of a document, it must be the active document. AS Set the active channels to the first and third channel using a channel array: set current channels of current document to ¬ { channel 1 of current document, channel 3 of current document } Alternatively, select all component channels using the component channels property of the Document object. set current channels of current document to component channels ¬ of current document VBS Set the active channels of the active document to the first and third channel using a channel array: ' This example assumes docRef is already the ActiveDocument Dim theChannels theChannels = Array(docRef.Channels(1), docRef.Channels(3)) docRef.ActiveChannels = theChannels Alternatively, select all component channels using the ComponentChannels property of the Document object: appRef.ActiveDocument.ActiveChannels= _ appRef.ActiveDocument.ComponentChannels JS Set the active channels to the first and third channel using a channel array: theChannels = new Array(docRef.channels[0], docRef.channels[2]) docRef.activeChannels = theChannels Alternatively, select all component channels by using the componentChannels property of the Document object: app.activeDocument.activeChannels = activeDocument.componentChannels Opening a Document You use the open/Open/open() command of the Application object to open an existing document. You must specify the document name (that is, the path to the file that contains the document) with the command. Opening a file with default file format Because Photoshop supports many different file formats, the open/Open/open() command lets you specify the format of the document you are opening. If you do not specify the format, Photoshop infers the type of file for you, which is called the file's default format. The following examples open a document by inferring the most appropriate format to use:

  • 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
Opening a Document
28
Setting the active channels
More than one channel can be active at a time, so the current
channels
(
ActiveChannels/activeChannels
) property of the
Document
object takes an array of channels as a
value. In order to set the active channels of a document, it must be the active document.
AS
Set the active channels to the first and third channel using a channel array:
set current channels of current document to ¬
{ channel 1 of current document, channel 3 of current document }
Alternatively, select all component channels using the
component
channels
property of the
Document
object.
set current channels of current document to component channels ¬
of current document
VBS
Set the active channels of the active document to the first and third channel using a channel array:
‘ This example assumes docRef is already the ActiveDocument
Dim theChannels
theChannels = Array(docRef.Channels(1), docRef.Channels(3))
docRef.ActiveChannels = theChannels
Alternatively, select all component channels using the
ComponentChannels
property of the
Document
object:
appRef.ActiveDocument.ActiveChannels= _
appRef.ActiveDocument.ComponentChannels
JS
Set the active channels to the first and third channel using a channel array:
theChannels = new Array(docRef.channels[0], docRef.channels[2])
docRef.activeChannels = theChannels
Alternatively, select all component channels by using the
componentChannels
property of the
Document
object:
app.activeDocument.activeChannels =
activeDocument.componentChannels
Opening a Document
You use the
open
/
Open
/
open()
command of the
Application
object to open an existing document. You
must specify the document name (that is, the path to the file that contains the document) with the
command.
Opening a file with default file format
Because Photoshop supports many different file formats, the
open/Open/open()
command lets you
specify the format of the document you are opening. If you do not specify the format, Photoshop infers
the type of file for you, which is called the file’s default format. The following examples open a document
by inferring the most appropriate format to use: