RasterItems
RasterItems
Section titled “RasterItems”app.activeDocument.rasterItems
Description
Section titled “Description”A collection of RasterItem objects.
Properties
Section titled “Properties”RasterItems.length
Section titled “RasterItems.length”app.activeDocument.rasterItems.length
Description
Section titled “Description”Number of elements in the collection.
Number; read-only.
RasterItems.parent
Section titled “RasterItems.parent”app.activeDocument.rasterItems.parent
Description
Section titled “Description”The object’s container.
Object; read-only.
RasterItems.typename
Section titled “RasterItems.typename”app.activeDocument.rasterItems.typename
Description
Section titled “Description”The class name of the object.
String; read-only.
Methods
Section titled “Methods”RasterItems.getByName()
Section titled “RasterItems.getByName()”app.activeDocument.rasterItems.getByName(name)
Description
Section titled “Description”Get the first element in the collection with the provided name.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
name | String | Name of element to get |
Returns
Section titled “Returns”RasterItems.index()
Section titled “RasterItems.index()”app.activeDocument.rasterItems.index(itemKey)
Description
Section titled “Description”Gets an element from the collection.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
itemKey | String, Number | String or number key |
Returns
Section titled “Returns”RasterItems.removeAll()
Section titled “RasterItems.removeAll()”app.activeDocument.rasterItems.removeAll()
Description
Section titled “Description”Deletes all elements in the collection.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Creating a raster item
Section titled “Creating a raster item”// Creates a new raster item in a new document from a raster file// jpgFilePath contains the full path and file name of a jpg filefunction 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();}
Finding and examining a raster item
Section titled “Finding and examining a raster item”// Examines the color space of the first raster item in the document and displays// result in ESTK consoleif (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; }}