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
O T E
:
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)