
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;