Script Optimization

Script Optimization

Problem

The processing of images takes too long.

Description

There are function settings and other adjustments that can be made to a script that will speed up processing to some degree.

Solution/Discussion

Try to avoid running any of the “drawing” functions on less than 15-bit data. These functions include arc(), drawText(), ellipse(), line(), polygon() and rectangle(). (Effectively, if the function uses the ‘smooth’ parameter, it will probably slow down on paletted image data.) Whenever feasible, use the convert() function to take the image data up to 24-bits before running these functions. Anti-aliasing slows down considerably when it is trying to detect and use the most appropriate colors from an image that has a limited palette.

Many of the functions that have the ‘radius’ parameter will run much longer as higher numbers are given to that parameter. These functions include, blur(), blurGaussianBlur(), otherHighPass(), otherMaximum(), otherMinimum(), sharpenUnsharpMask() and stylizeDiffuse(). Using a number of 5 or less will usually produce satisfactory results, while even slightly higher numbers will greatly add to the processing time.

When an image is scaled to a smaller size than the original, there is often no need to use the more processor-intensive algorithms of ‘smooth’ or ‘best.’ In almost every case, the default ‘fast’ setting will produce results qualitatively similar to those from the other two algorithms and cut processing time by as much as half.

When an original image is extremely large, when the final result is never used at its full original size, and especially when it will be used as a source for several different scripts, it is best to replace it with an image that is already scaled down to something nearer the largest size needed or, preferably, exactly the largest size needed.

Whenever possible, avoid using multiframe images as sources for a MediaScript. Even when the ‘frame’ parameter is used for the load() function, the entire set of frames must be opened into memory to find the frame or frames that will actually be processed.

Back to Developer Resources

MediaRich Brochure

Equilibrium Solutions Brochure