A SERVICE OF

logo

MediaScript Objects and Methods 45
Example
This example returns a text file describing all of the available file formats.
#include "sys:/TextResponse.ms"
function main()
{
var foo = Media.getFileFormats();
var txt = new TextResponse();
for (var i = 0; i < foo.length; ++i)
{
txt.append(foo[i].type + ":\n");
txt.append(" exts: " + foo[i].extensions + "\n");
txt.append(" flags: ");
if (foo[i].flags & Media.FormatLoad)
txt.append("load ");
if (foo[i].flags & Media.FormatSave)
txt.append("save ");
if (foo[i].flags & Media.FormatCmykSave)
txt.append("cmyk");
txt.append("\n");
}
resp.setObject(txt, RespType.Streamed);
}
getExtensionFromType()
Returns the file system extension (such as “jpg”) for the given the media type.
Syntax
var extension = Media.getExtensionFromType(
<"type">
);
Parameters
type - the media type (such as “jpeg”, “tiff”, etc.).
getTypeFromExtension()
Returns the media type for the given the extension.
Syntax
var type = Media.getTypeFromExtension(
<"extension">
);