A SERVICE OF

logo

MediaScript Objects and Methods 121
MediaRich also allows you to set up virtual file systems and then use the Name parameter
to load palettes from a virtual file system. Virtual file systems are defined in the MediaRich
server’s local.properties file. For example, if you define “MyPalettes:” to represent
the path “C:/PALS/MyPalettes/” in the local.properties file, you can use files from
the MyPalettes directory with the reduce() function:
image.reduce(name @ "MyPalettes:/custom.pal");
NOTE: You may need to experiment with dithering and dithertop levels to achieve the results you
want in the palette you use. For example, palettes with a bit-depth between 128 and 256 seem to
appear best with a Dither value of 8 and a Dithertop value of 6.
image.reduce(Name @ "Palettes/Windows_256.pal");
Colors - specifies the number of palette colors to be generated and applied. In the case of
a media with multiple frames, all the frames are reduced to one palette based on the
contents of all the frames.
NOTE: The Notbackcolor parameter has been deprecated.
Dither - determines the level of dithering to use for remapping image pixels to the palette.
The default is zero, which is no dithering. While the dither value ranges from 0 to 10, the
actual effects of different values vary according to the number of colors in the palette and
their spread relative to each other.
Dithertop - if set to “true” when dithering is used, sets an upper threshold of how far the
dithering algorithm will go to pick a color in order to correct color balance. The default
value is 10. When an optimal (custom) palette is used, lowering the value of dithertop
tends to reduce the pixelization of the image, making the dithering effect softer.
layers - for PSD files, specifies the layers to be affected. The layer numbers begin at 0
(background) and go up. For more information see “load()” on page 101.
Example
var image = new Media();
image.load(name @ "car.tga");
image.reduce(colors @ 256, dither @ 3, pad @ true);
image.save(type @ "jpeg");