Adobe 23101764 Scripting Guide - Page 97

Getting and converting colors

Page 97 highlights

Scripting Photoshop 3 Color objects 3.15.2 Getting and converting colors Here's how to get the foreground color in AppleScript. get foreground color This may return an RGB color and in some cases you may want the CMYK equivalent. To convert an RGB color to CMYK in AppleScript you would write: convert color foreground color to CMYK VB/JS: The foreground color returns a SolidColor object. You should use its model property to determine the color model. If (someColor.model = ColorModel.RGB) Then alert("It's an RGB color") End If You can also ask the SolidColor object to convert its color to any of the supported models. For example, writing: someColor.cmyk will return a CMYKColor object representing the CMYK version of the color in someColor regardless of the color model of someColor. The examples below show how to convert the foreground color to a Lab color. AS: -- Convert foreground application color to Lab set myLabColor to convert color foreground color to Lab VB: ' Get the foreground color as Lab Dim myLabColor As Photoshop.LabColor Set myLabColor = appRef.ForegroundColor.Lab JS: // Get the Lab color from the foreground color. var myLabColor = foregroundColor.lab; Photoshop CS Scripting Guide 93

  • 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
93
Scripting Photoshop
Color objects
3
3.15.2
Getting and converting colors
Here’s how to get the foreground color in AppleScript.
get foreground color
This may return an RGB color and in some cases you may want the CMYK equivalent. To
convert an RGB color to CMYK in AppleScript you would write:
convert color foreground color to CMYK
VB/JS:
The foreground color returns a SolidColor object. You should use its
model
property to
determine the color model.
If (someColor.model = ColorModel.RGB) Then
alert("It's an RGB color")
End If
You can also ask the
SolidColor
object to convert its color to any of the supported models.
For example, writing:
someColor.cmyk
will return a CMYKColor object representing the CMYK version of the color in
someColor
regardless of the color model of someColor.
The examples below show how to convert the foreground color to a Lab color.
AS:
-- Convert foreground application color to Lab
set myLabColor to convert color foreground color to Lab
VB:
' Get the foreground color as Lab
Dim myLabColor As Photoshop.LabColor
Set myLabColor = appRef.ForegroundColor.Lab
JS:
// Get the Lab color from the foreground color.
var myLabColor = foregroundColor.lab;