Adobe 23101764 Scripting Guide - Page 92

Working with Filters

Page 92 highlights

Scripting Photoshop 3 Working with Filters To restore a selection that has been saved to a selection, use the load (Load/load) method as shown below. AS: load selection of current document from channel "My Channel" of ¬ current document combination type extended VB: selRef.Load docRef.Channels("My Channel"), psExtendSelection JS: selRef.load (docRef.channels["My Channel"], SelectionType.EXTEND); See section 3.17, "Clipboard interaction" on page 96 for examples on how to copy, cut and paste selections. 3.13 Working with Filters To apply a filter, use the layer's filter command for AppleScript or the ApplyXXX/applyXXX methods for Visual Basic and JavaScript. The following examples apply the Gaussian blur filter to the active layer. AS: filter current layer of current document using Gaussian blur ¬ with options { radius: 5 } VB: docRef.ActiveLayer.ApplyGaussianBlur 5 JS: docRef.activeLayer.applyGaussianBlur(5); 3.13.1 Selecting channel(s) to filter When applying filters, keep in mind they affect the selected channels of a visible layer. This means that prior to running a filter, you may have to set the active channels. Since more than one channel can be active at a time, you must provide an array of channels when setting a channel. The code below demonstrates how to set the active channels to the channels named "Red" and "Blue." AS: set current channels of current document to { channel "Red" of ¬ current document, channel "Blue" of current document } Photoshop CS Scripting Guide 88

  • 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
88
Scripting Photoshop
Working with Filters
3
To restore a selection that has been saved to a selection, use the load (Load/load) method as
shown below.
AS:
load selection of current document from channel "My Channel" of ¬
current document combination type extended
VB:
selRef.Load docRef.Channels("My Channel"), psExtendSelection
JS:
selRef.load (docRef.channels["My Channel"], SelectionType.EXTEND);
See section
3.17, “Clipboard interaction” on page 96
for examples on how to copy, cut and
paste selections.
3.13 Working with Filters
To apply a
lter, use the layer's
filter
command for AppleScript or the
ApplyXXX/applyXXX
methods for Visual Basic and JavaScript. The following examples
apply the Gaussian blur
lter to the active layer.
AS:
filter current layer of current document using Gaussian blur ¬
with options { radius: 5 }
VB:
docRef.ActiveLayer.ApplyGaussianBlur 5
JS:
docRef.activeLayer.applyGaussianBlur(5);
3.13.1
Selecting channel(s) to
lter
When applying
lters, keep in mind they affect the selected channels of a visible layer. This
means that prior to running a
lter, you may have to set the active channels. Since more than
one channel can be active at a time, you must provide an array of channels when setting a
channel. The code below demonstrates how to set the active channels to the channels named
“Red” and “Blue.”
AS:
set current channels of current document to { channel "Red" of ¬
current document, channel "Blue" of current document }