Adobe 65014293 Scripting Guide - Page 53

Comparing colors, Getting a Web-safe color, Working with Filters

Page 53 highlights

CHAPTER 3: Scripting Photoshop Working with Filters 53 Look up the following in the Adobe Photoshop CS4 Visual Basic Scripting Reference, or in the Visual Basic Object Browser: ➤ model and cmyk as properties of the SolidColor object JS This example uses the foregroundColor property of the Application object to get the original color to be converted. The cmyk property of the SolidColor object that foregroundColor refers to provides a way to access the cmyk equivalent of the rgb color. var someColor = foregroundColor.cmyk Look up the following in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer: ➤ cmyk as a property of the SolidColor object ➤ foregroundColor as a property of the Application object Comparing colors Using the equal colors (IsEqual/isEqual) command, you can compare colors. The following statements return true if the foreground color is visually equal to background color. ➤ AS: if equal colors foreground color with background color then ➤ VBS: If (appRef.ForegroundColor.IsEqual(appRef.BackgroundColor)) Then ➤ JS: if (app.foregroundColor.isEqual(backgroundColor)) Getting a Web-safe color AS VBS JS To convert a color to a web safe color use the web safe color command on AppleScript and the NearestWebColor/nearestWebColor property of the SolidColor object for VBScript and JavaScript. set myWebSafeColor to web safe color for foreground color Dim myWebSafeColor Set myWebSafeColor = appRef.ForegroundColor.NearestWebColor var webSafeColor = new RGBColor() webSafeColor = app.foregroundColor.nearestWebColor Working with Filters To apply a filter in AppleScript, you use the filter command with an option from the class filter options. In VBScript and JavaScript, you use a specific filter method. For example, to apply a Gaussian blur filter, you use the ApplyGaussianBlur/applyGaussianBlur() method. All filter methods belong to the ArtLayer object. NOTE: Please refer to Photoshop Help for information about the effects produced by individual filter types. The following examples apply the Gaussian blur filter to the active layer.

  • 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 Filters
53
Look up the following in the
Adobe Photoshop CS4 Visual Basic Scripting Reference
, or in the Visual Basic
Object Browser:
model
and
cmyk
as properties of the
SolidColor
object
JS
This example uses the
foregroundColor
property of the
Application
object to get the original color to
be converted. The
cmyk
property of the
SolidColor
object that
foregroundColor
refers to provides a
way to access the cmyk equivalent of the rgb color.
var someColor = foregroundColor.cmyk
Look up the following in the
Adobe Photoshop CS4 JavaScript Scripting Reference
, or in the ExtendScript
Object Model Viewer:
cmyk
as a property of the
SolidColor
object
foregroundColor
as a property of the
Application
object
Comparing colors
Using the
equal
colors (IsEqual/isEqual)
command, you can compare colors. The following
statements return
true
if the foreground color is visually equal to background color.
AS:
if equal colors foreground color with background color then
VBS:
If
(appRef.ForegroundColor.IsEqual(appRef.BackgroundColor)) Then
JS:
if (app.foregroundColor.isEqual(backgroundColor))
Getting a Web-safe color
To convert a color to a web safe color use the
web
safe
color
command on AppleScript and the
NearestWebColor/nearestWebColor
property of the
SolidColor
object for VBScript and JavaScript.
AS
set myWebSafeColor to web safe color for foreground color
VBS
Dim myWebSafeColor
Set myWebSafeColor = appRef.ForegroundColor.NearestWebColor
JS
var webSafeColor = new RGBColor()
webSafeColor = app.foregroundColor.nearestWebColor
Working with Filters
To apply a filter in AppleScript, you use the
filter
command with an option from the class
filter
options
. In VBScript and JavaScript, you use a specific filter method. For example, to apply a Gaussian blur
filter, you use the
ApplyGaussianBlur/applyGaussianBlur()
method. All filter methods belong to the
ArtLayer
object.
N
OTE
:
Please refer to Photoshop Help for information about the effects produced by individual filter types.
The following examples apply the Gaussian blur filter to the active layer.