Layer Creation
addImageLayer()
Add an image layer from raw RGBA pixel data.
options
ImageLayerOptions
required
Raw RGBA pixel data (ArrayBuffer, Uint8Array, or array-like)
Parent group layer ID (if adding to a group)
const layerId = comp.addImageLayer({
name: 'sprite',
rgba: pixelData,
width: 128,
height: 128,
x: 10,
y: 20
});
addPaintLayer()
Add an empty editable paint layer.
options
PaintLayerOptions
required
Parent group layer ID (not currently supported)
const paintId = comp.addPaintLayer({
name: 'drawing',
width: 256,
height: 256
});
addFilterLayer()
Add an HSL filter adjustment layer.
options
FilterLayerOptions
required
Parent group layer ID (applies filter to group contents)
const filterId = comp.addFilterLayer({ name: 'color adjust' });
comp.setFilterLayerConfig(filterId, {
hueDeg: 30,
saturation: 0.2,
brightness: 0.1
});
addGroupLayer()
Add a group layer to organize nested layers.
options
GroupLayerOptions
required
Parent group layer ID (for nested groups)
const groupId = comp.addGroupLayer({ name: 'effects' });
addSolidColorLayer()
Add a solid color fill layer.
options
SolidColorLayerOptions
required
RGBA color (4-byte array)
Parent group layer ID (not currently supported)
const bgId = comp.addSolidColorLayer({
name: 'background',
color: [255, 255, 255, 255]
});
addGradientLayer()
Add a gradient fill layer.
options
GradientLayerOptions
required
Array of gradient stops with position (0-1) and color
direction
GradientDirection
default:"horizontal"
Gradient direction: “horizontal”, “vertical”, “diagonalDown”, “diagonalUp”, or 0-3
Parent group layer ID (not currently supported)
const gradId = comp.addGradientLayer({
name: 'gradient',
stops: [
{ position: 0, color: [255, 0, 0, 255] },
{ position: 1, color: [0, 0, 255, 255] }
],
direction: 'vertical'
});
addPngLayer()
Decode a PNG and add as an image layer.
Parent group layer ID (not currently supported)
const layerId = comp.addPngLayer({
name: 'logo',
png: pngBytes,
x: 50,
y: 50
});
Layer Import
importImage()
Auto-detect format and import as a layer.
options
ImportImageOptions
required
Image data (PNG, JPEG, WebP, or GIF)
const layerId = comp.importImage({
name: 'photo',
bytes: imageBytes
});
importJpeg()
Decode a JPEG and add as a layer.
const layerId = comp.importJpeg({
name: 'photo',
bytes: jpegBytes,
x: 0,
y: 0
});
importWebp()
Decode a WebP and add as a layer.
const layerId = comp.importWebp({
name: 'image',
bytes: webpBytes
});
importGifFrames()
Decode a GIF and add each frame as a separate layer.
options
{ bytes: ByteInput }
required
Array of created layer IDs (one per frame)
const frameIds = comp.importGifFrames({ bytes: gifBytes });
importPsd()
Import PSD layers (experimental).
options
{ bytes: ByteInput }
required
Array of created layer IDs
const layerIds = comp.importPsd({ bytes: psdBytes });
Layer Management
updateLayer()
Update layer properties with a patch object.
Transform anchor: “topLeft”, “center”, 0, or 1
Filter settings (for filter layers)
True if layer was found and updated
comp.updateLayer(layerId, {
opacity: 0.8,
rotation: 45,
scaleX: 1.5,
anchor: 'center'
});
removeLayer()
Delete a layer by ID.
True if layer was found and removed
const removed = comp.removeLayer(layerId);
moveLayer()
Move a layer to a new parent and/or index.
New parent group ID (null for top level)
Index within parent’s children
comp.moveLayer(layerId, { parentId: null, index: 0 });
getLayer()
Get layer metadata.
Layer metadata object or null if not found
const layer = comp.getLayer(layerId);
console.log(layer.name, layer.width, layer.height);
listLayers()
List layers with optional filtering.
List children of this group (null for top level)
Include nested descendants
Array of layer metadata objects
const allLayers = comp.listLayers();
const groupChildren = comp.listLayers({ parentId: groupId, recursive: false });
layerCount()
Get the number of top-level layers.
Number of top-level layers
const count = comp.layerCount();
Group Operations
flattenGroup()
Flatten a group layer into a single image layer.
True if group was flattened
comp.flattenGroup(groupId);
removeFromGroup()
Remove a child from a group.
True if child was removed
comp.removeFromGroup(groupId, childId);
Layer Data
getLayerRgba()
Get a layer’s raw RGBA pixel buffer.
Raw RGBA pixel data (or empty array if not an image/paint/shape layer)
const pixels = comp.getLayerRgba(layerId);