Adobe 23101764 Scripting Guide - Page 94

Setting the active channel, Creating new channels

Page 94 highlights

Scripting Photoshop 3 Channel object If you have an RGB document you automatically get a red, blue and a green channel. These kinds of channels are related to the document mode and are called "component channels." A Channel has a kind property you can use to get and set the type of the channel. Possible values are: component channel, masked area channel, selected area channel and spot color channel. You cannot change the kind of a component channel. But you could change a "masked area channel" to be "selected area channel" by saying: AS: set kind of myChannel to selected area channel VB: channelRef.kind = psSelectedAreaAlphaChannel JS: channelRef.kind = ChannelType.SELECTEDAREA; NOTE: You cannot use book colors or convert document mode to duo-tone. 3.14.2 Setting the active channel Because more than one channel can be active at a time, when setting a channel, you must provide a channel array. The sample below demonstrates how to set the active channels to the first and third channel. AS: set current channels of current document to ¬ { channel 1 of current document, channel 3 of current document } VB: Dim theChannels As Variant theChannels = Array(docRef.Channels(1), docRef.Channels(3)) docRef.ActiveChannels = theChannels JS: theChannels = new Array(docRef.channels[0], docRef.channels[2]); docRef.activeChannels = theChannels; Deleting a component will change the document to a multi-channel document. 3.14.3 Creating new channels You can create three different types of channels from a script. These types are: • masked area channel (psMaskedAreaAlphaChannel, ChannelType.MASKEDAREA) • selected area channel (psSelectedAreaAlphaChannel, ChannelType. SELECTEDAREA) Photoshop CS Scripting Guide 90

  • 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
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
90
Scripting Photoshop
Channel object
3
If you have an RGB document you automatically get a red, blue and a green channel. These
kinds of channels are related to the document mode and are called “component channels.”
A Channel has a
kind
property you can use to get and set the type of the channel. Possible
values are:
component channel, masked area channel, selected area
channel
and
spot color channel
.
You cannot change the kind of a component channel. But you could change a “masked area
channel” to be “selected area channel” by saying:
AS:
set kind of myChannel to selected area channel
VB:
channelRef.kind = psSelectedAreaAlphaChannel
JS:
channelRef.kind = ChannelType.SELECTEDAREA;
N
OTE
:
You cannot use book colors or convert document mode to duo-tone.
3.14.2
Setting the active channel
Because more than one channel can be active at a time, when setting a channel, you must
provide a channel array. The sample below demonstrates how to set the active channels to the
rst and third channel.
AS:
set current channels of current document to ¬
{ channel 1 of current document, channel 3 of current document
}
VB:
Dim theChannels As Variant
theChannels = Array(docRef.Channels(1), docRef.Channels(3))
docRef.ActiveChannels = theChannels
JS:
theChannels = new Array(docRef.channels[0], docRef.channels[2]);
docRef.activeChannels = theChannels;
Deleting a component will change the document to a multi-channel document.
3.14.3
Creating new channels
You can create three different types of channels from a script. These types are:
masked area channel (psMaskedAreaAlphaChannel,
ChannelType.MASKEDAREA)
selected area channel (psSelectedAreaAlphaChannel, ChannelType.
SELECTEDAREA)