Adobe 65048599 Scripting Guide - Page 46

Working with Channel objects, Changing channel types

Page 46 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 46 AS VBS JS AS VBS JS examples use the store (Store/store()) command of the Selection object to store the current selection in a channel named My Channel and extend the selection with any selection that is currently in that channel. set myChannel to make new channel of current document with properties ¬ {name:"My Channel", kind::selected area channel} store selection of current document into channel ¬ "My Channel" of current document combination type extended Set chanRef = docRef.Channels.Add chanRef.Name = "My Channel" chanRef.Kind = 3 'psSelectedAreaAlphaChannel docRef.Selection.Store docRef.Channels("My Channel"), 2 'PsSelectionType is 2 (psExtendSelection) var chanRef = docRef.channels.add() chanRef.name = "My Channel" chanRef.kind = ChannelType.SELECTEDAREA docRef.selection.store(docRef.channels["My Channel"], SelectionType.EXTEND) To restore a selection that has been saved to a Channel object, use the load (Load/load) method. set myChannel to make new channel of current document with properties ¬ {name:"My Channel"} load selection of current document from channel "My Channel" of ¬ current document combination type extended selRef.Load docRef.Channels("My Channel"), 2 'PsSelectionType is 2 (psExtendSelection) selRef.load (docRef.channels["My Channel"], SelectionType.EXTEND) See section "Understanding Clipboard Interaction" on page 54 for examples on how to copy, cut and paste selections. Working with Channel objects The Channel object gives you access to much of the available functionality on Photoshop channels. You can create, delete, and duplicate channels or retrieve a channel's histogram and change its kind. See "Creating New Objects in a Script" on page 23 for information on creating a Channel object in your script. You can set or get (that is, find out about) a Channel object's type using the kind property. See "Loading and storing selections" on page 45 for script samples that demonstrate how to create a selected area channel. Changing channel types You can change the kind of any channel except component channels. The following examples demonstrate how to change a masked area channel to a selected area channel: NOTE: Component channels are related to the document mode. Refer to Photoshop Help for information on channels, channel types, and document modes.

  • 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
46
examples use the
store
(Store/store())
command of the
Selection
object to store the current
selection in a channel named
My
Channel
and extend the selection with any selection that is currently in
that channel.
AS
set myChannel to make new channel of current document with properties ¬
{name:"My Channel", kind::selected area channel}
store selection of current document into channel ¬
"My Channel" of current document combination type extended
VBS
Set chanRef = docRef.Channels.Add
chanRef.Name = "My Channel"
chanRef.Kind = 3 'psSelectedAreaAlphaChannel
docRef.Selection.Store docRef.Channels("My Channel"), 2
'PsSelectionType is 2 (psExtendSelection)
JS
var chanRef = docRef.channels.add()
chanRef.name = "My Channel"
chanRef.kind = ChannelType.SELECTEDAREA
docRef.selection.store(docRef.channels["My Channel"], SelectionType.EXTEND)
To restore a selection that has been saved to a
Channel
object, use the
load (Load/load)
method.
AS
set myChannel to make new channel of current document with properties ¬
{name:"My Channel"}
load selection of current document from channel "My Channel" of ¬
current document combination type extended
VBS
selRef.Load docRef.Channels("My Channel"), 2
'PsSelectionType is 2 (psExtendSelection)
JS
selRef.load (docRef.channels["My Channel"], SelectionType.EXTEND)
See section
“Understanding Clipboard Interaction” on page 54
for examples on how to copy, cut and paste
selections.
Working with Channel objects
The
Channel
object gives you access to much of the available functionality on Photoshop channels. You
can create, delete, and duplicate channels or retrieve a channel's histogram and change its kind. See
“Creating New Objects in a Script” on page 23
for information on creating a
Channel
object in your script.
You can set or get (that is, find out about) a
Channel
object’s type using the
kind
property. See
“Loading
and storing selections” on page 45
for script samples that demonstrate how to create a selected area
channel.
Changing channel types
You can change the
kind
of any channel except component channels. The following examples
demonstrate how to change a masked area channel to a selected area channel:
N
OTE
:
Component channels are related to the document mode. Refer to Photoshop Help for information
on channels, channel types, and document modes.