Skip to main content

Layer Creation

addImageLayer()

Add an image layer from raw RGBA pixel data.
options
ImageLayerOptions
required
layerId
number
The created layer’s ID
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
layerId
number
The created layer’s ID
const paintId = comp.addPaintLayer({
  name: 'drawing',
  width: 256,
  height: 256
});

addFilterLayer()

Add an HSL filter adjustment layer.
options
FilterLayerOptions
required
layerId
number
The created layer’s ID
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
layerId
number
The created layer’s ID
const groupId = comp.addGroupLayer({ name: 'effects' });

addSolidColorLayer()

Add a solid color fill layer.
options
SolidColorLayerOptions
required
layerId
number
The created layer’s ID
const bgId = comp.addSolidColorLayer({
  name: 'background',
  color: [255, 255, 255, 255]
});

addGradientLayer()

Add a gradient fill layer.
options
GradientLayerOptions
required
layerId
number
The created layer’s ID
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.
options
PngLayerOptions
required
layerId
number
The created layer’s ID
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
layerId
number
The created layer’s ID
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
layerIds
Uint32Array
Array of created layer IDs (one per frame)
const frameIds = comp.importGifFrames({ bytes: gifBytes });

importPsd()

Import PSD layers (experimental).
options
{ bytes: ByteInput }
required
layerIds
Uint32Array
Array of created layer IDs
const layerIds = comp.importPsd({ bytes: psdBytes });

Layer Management

updateLayer()

Update layer properties with a patch object.
id
number
required
Layer ID
patch
LayerUpdate
required
success
boolean
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.
id
number
required
Layer ID
success
boolean
True if layer was found and removed
const removed = comp.removeLayer(layerId);

moveLayer()

Move a layer to a new parent and/or index.
id
number
required
Layer ID to move
target
MoveLayerTarget
required
success
boolean
True if layer was moved
comp.moveLayer(layerId, { parentId: null, index: 0 });

getLayer()

Get layer metadata.
id
number
required
Layer ID
layer
LayerInfo | null
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.
options
ListLayersOptions
layers
LayerInfo[]
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.
count
number
Number of top-level layers
const count = comp.layerCount();

Group Operations

flattenGroup()

Flatten a group layer into a single image layer.
groupId
number
required
Group layer ID
success
boolean
True if group was flattened
comp.flattenGroup(groupId);

removeFromGroup()

Remove a child from a group.
groupId
number
required
Group layer ID
childId
number
required
Child layer ID to remove
success
boolean
True if child was removed
comp.removeFromGroup(groupId, childId);

Layer Data

getLayerRgba()

Get a layer’s raw RGBA pixel buffer.
id
number
required
Layer ID
rgba
Uint8Array
Raw RGBA pixel data (or empty array if not an image/paint/shape layer)
const pixels = comp.getLayerRgba(layerId);

Build docs developers (and LLMs) love