Skip to content

RasterItems

app.activeDocument.rasterItems

A collection of RasterItem objects.


app.activeDocument.rasterItems.length

Number of elements in the collection.

Number; read-only.


app.activeDocument.rasterItems.parent

The object’s container.

Object; read-only.


app.activeDocument.rasterItems.typename

The class name of the object.

String; read-only.


app.activeDocument.rasterItems.getByName(name)

Get the first element in the collection with the provided name.

ParameterTypeDescription
nameStringName of element to get

SymbolItem


app.activeDocument.rasterItems.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

SymbolItem


app.activeDocument.rasterItems.removeAll()

Deletes all elements in the collection.

Nothing.


// Creates a new raster item in a new document from a raster file
// jpgFilePath contains the full path and file name of a jpg file
function createRasterItem(jpgFilePath) {
var rasterFile = File(jpgFilePath);
var myDoc = app.documents.add();
var myPlacedItem = myDoc.placedItems.add();
myPlacedItem.file = rasterFile;
myPlacedItem.position = Array(0, myDoc.height);
myPlacedItem.embed();
}
// Examines the color space of the first raster item in the document and displays
// result in ESTK console
if (app.documents.length > 0 && app.activeDocument.rasterItems.length > 0) {
var rasterArt = app.activeDocument.rasterItems[0];
switch (rasterArt.imageColorSpace) {
case ImageColorSpace.CMYK:
$.writeln("The color space of the first raster item is CMYK");
break;
case ImageColorSpace.RGB:
$.writeln("The color space of the first raster item is RGB");
break;
case ImageColorSpace.GRAYSCALE:
$.writeln("The color space of the first raster item is GRAYSCALE");
break;
}
}