
132 Chapter 3
•
•
•
•
•
For all other images:
Background color will be black.
Foreground color will be white.
NOTE: If the image’s file type supports them and its background, transparency and/or foreground
colors have been set, those values will be used.
Unless specifically changed, the initial values will be retained and used throughout all
subsequent transformations. To be sure of the values used, it is best to use specific settings.
Syntax
setColor(
[BackColor @ <color in hexadecimal or rgb>]
[ForeColor @ <color in hexadecimal or rgb>]
[BackIndex @ <value 0..16777215>]
[ForeIndex @ <value 0..16777215>]
[Transparency @ (true, false)]
[Popular @ (true, false)]
[Precise <true, false>]
[layers @ <"layer list">] // (PSD files only)
);
Parameters
Backcolor - specifies the background color as a specific RGB or hexidecimal value.
Forecolor - specifies the foreground color as a specific RGB or hexidecimal value.
Backindex - specifies the background color as an index value. Direct indexing is primarily
used for indexed images, but can be used for any image type to select a specific pixel value.
Foreindex - specifies the foreground color as an index value.
Transparency - if this parameter is set to “false”, the whole image is considered opaque.
If set to “true”, the pixels in the image that match the background color are considered
transparent. Transparency is typically used when generating an alpha channel for an image
(such as compositing an image that is not 32-bit). Transparency is also supported when
saving to the GIF format and, if 8-bit or less, to the PNG format.
Popular - if set to “true”, finds the most popular color or index in the image. For images
above 16-bit color depth, the image is processed at 18-bit resolution.
NOTE: The Popular parameter overrides any settings specified by the Backcolor,
Forecolor, Backindex or Foreindex parameter. In addition, this parameter does not
support the CMYK color-space.
Precise - If Popular is specified and this is set to “true”, the method uses precision in
the calculation of the most popular color. If set to false (default), the color returned will be
a close approximation of the actual color that appears most often in the image.
layers - for PSD files, specifies the layers to be included. The layer numbers begin at 0
(background) and go up. For more information see “load()” on page 101.