Shayton Equilibrium Kitchen Utensil 2003 User Manual

Page of 194
 
8
 
 
 Chapter 1 
 
• 
• 
• 
 
Using the processImage Function
 
The MediaScript API for SharePoint is comprised of a single function your script must 
define. This enables the script to function correctly both as an Export script and a 
MediaCart script. In the case of the MediaCart, the same script is used for each image in a 
MediaCart batch. 
 
Syntax 
 
Media processImage(Media image)
 
The 
 
processImage
 
 function is the single entry point for all scripts that interoperate with 
the MediaRich for SharePoint Connector. 
 
Parameters
 
The 
 
processImage
 
 function takes a Media object as its single argument. This object is an 
image from a Windows SharePoint Services site on which operations are performed. 
 
Return 
 
Your 
 
processImage
 
 function must return a Media object. 
 
Example
 
The following sample script, named “
 
save image as jpg.ms
 
”, specifies that an 
arbitrary input image should be saved using the JPG file format: 
 
function processImage(image) {
    var saveParams = resp.getSaveParameters();
    saveParams.type = "jpg";
 resp.setSaveParameters(saveParams);
 return image; } 
 
The first line: 
 
function processImage(image) { 
 
starts the definition of the 
 
processImage
 
 function. It is expecting to be passed a Media 
object named “image”. 
This script requires a little more information from the system, so the next thing to do is get 
this information: 
 
var saveParams = resp.getSaveParameters(); 
 
This makes use of another object provided by the system, the Response object named 
 
resp
 
” that is available to all MediaScripts, and gets its save parameters. 
The next line sets a save parameter: 
 
saveParams.type = "jpg";