
MediaScript Objects and Methods 129
•
•
•
•
PreserveBackgroundCutoff - specifies the threshold for PreserveBackground. The
default threshold percentage is 67%, which means that the background color will be
preserved unless 67% or more of the pixels use the background color.
Padcolor or Padindex - specifies the color to be used where the new image dimensions
extend beyond the current image. If a pad color is not specified, the image’s background
color is used by default. For more information about setting an image’s background color,
see setColor().
Transparency - specifies the transparency (255 is opaque and 0 is transparent) of the
padded area’s alpha channel. This parameter is useful when the cropped image is used in
a composite().
NOTE: If the cropped image is not 32-bit before cropping, the transparency information is not used
on the next composite() function.
TransparentCutoff - specifies a value that controls the selection of the transparent pixel
when scaling images with color palette. If the scaled alpha channel value is less than or
equal to the transparentCutoff value, the transparent pixel is selected. A value of -1
(default) ignores the scaled alpha value and performs the normal reverse color lookup.
Example
var image = new Media();
image.load(name @ "pasta.tga");
image.scale(xs @ "75%", constrain @ true);
image.save(type @ "jpeg");
selection()
Creates a selection from the specified Media object.
The selected area can be thought of as a grayscale image or alpha channel that determines
the way in which a given transform is applied to an image. Where the selection is 255, the
transform or function is applied to the image pixel; where the selection is zero, the
transform is not applied. In cases where the selection is between 1 and 254, the transform
is applied to the source pixel, and the result is then blended with the original pixel based
on the selection value. This function also fully supports the CMYK color-space.
NOTE: If using with two source images, both images must be the same size. This can be
accomplished with the scale(), getHeight(), or getWidth() function.