User's Manual
MediaScript Objects and Methods 97
•
•
•
•
•
importChannel()
Imports the specified source image (treated as a grayscale) and replaces the selected
channel in the original. It is important that both images must be the same size. Before you
can import an image, you must load() it.
NOTE: This function was formerly named importGun(), which has been deprecated.
NOTE: Color value parameters to functions supporting CMYK are interpreted as CMYK colors if
the raster to which they are applied is CMYK.
Syntax
importChannel(
Channel @ <"channel name">
[Source @ <user-defined Media object name>]
[layers @ <"layer list">] // (PSD files only)
[RType @ <"bit-depth">]
);
Parameters
Source - specifies the image to add by its user-defined Media object name.
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.
Rtype - specifies the target bit depth. The supported bit depths: “RGB-24”, “RGBA-32”,
“CMYK-32”, “CMYKA-40”, “Gray-8”, “RGB-15”, “RGB-16”, “RGBA-16”, “RGB-18”,
“Alpha-8”, “HLS-24”, “HSV-24”.
Valid channel names are:
•
“Blue”, “Green”, “Red”, “Alpha”,
•
“Cyan”, “Magenta”, “Yellow”, “Black” (CMYK-space)
•
“Brightness”, “Saturation”, “Hue” (HSV-space)
•
“Brightness2”, “Saturation2”, “Hue2” (HLS-space)
The default value is Blue.
NOTE: If you attempt to import an alpha channel into a 24-bit image, it will automatically be
converted to a 32-bit image.
Example
var image1 = new Media();
var image2 = new Media();
image1.load(name @ "peppers.tga");
image2.load(name @ "Bears.tga");
image2.scale(xs @ image1.getWidth(), ys @ image1.getHeight());
image1.importChannel(channel @ "red", source @ image2);
image1.save(type @ "jpeg");










