Compositor

v0.1.4
io.github.Josusanz/compositor Checked 3 days ago Published 2 months ago

Read and edit Compositor .comp projects: layers, folders, masks, transforms, previews and exports

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

inspect_project Inspect project

Reads a Compositor .comp project and returns the canvas info plus every layer in stacking order (bottom to top), with folder depth, visibility, opacity, blend mode and transform.

ParameterTypeDescription
path *stringPath to the .comp project package (a directory ending in .comp)

list_layers List layers

Compact list of layers (id, name, kind, visibility) from top to bottom as shown in Compositor's Layers panel.

ParameterTypeDescription
path *stringPath to the .comp project package (a directory ending in .comp)

render_preview Render preview

Flattens the project and returns a PNG preview image so the model can see the composition. Optionally saves it to a file. Clipping masks, adjustment layers and layer effects are not rendered; the response lists what was skipped.

ParameterTypeDescription
path *stringPath to the .comp project package (a directory ending in .comp)
maxSizeintegerLongest side of the preview in pixels
outputPathstringIf given, also writes the preview (PNG or JPEG by extension) to this path

export_flattened Export flattened image

Renders the whole project at full resolution to a PNG or JPEG file.

ParameterTypeDescription
outputPath *stringDestination file; .png keeps transparency, .jpg flattens onto white
path *stringPath to the .comp project package (a directory ending in .comp)
qualityintegerJPEG quality

export_layer Export a layer's pixels

Copies a pixel layer's source PNG (untransformed, original resolution) or its mask to a file.

ParameterTypeDescription
layer *stringLayer UUID or its exact name
outputPath *string
path *stringPath to the .comp project package (a directory ending in .comp)
whatstring

create_project Create project

Creates a new empty .comp project. Optionally adds a solid background layer. Overwrites the manifest of an existing package at that path.

ParameterTypeDescription
height *integer
path *stringPath to the .comp project package (a directory ending in .comp)
width *integer
backgroundstringCSS color for a Background layer, e.g. #ffffff. Omit for a transparent document.
resolutionnumberPixels per inch (default 72)

add_image_layer Add image layer

Imports an image file (PNG, JPEG, HEIC, TIFF, WebP…) as a new pixel layer. The pixels are stored as-is; the placement only sets the layer's transform.

ParameterTypeDescription
imagePath *stringImage file to import
path *stringPath to the .comp project package (a directory ending in .comp)
abovestringPlace directly above this layer (id or name)
belowstringPlace directly below this layer (id or name)
blendModestring
namestringLayer name (defaults to the file name)
opacitynumber
originarrayExplicit top-left position in canvas pixels; overrides centering
parentstringFolder (id or name) to put the layer in; omit for the root
placementstringoriginal: 1:1 pixels centered; fit: scale to fit inside the canvas; fill: scale to cover the canvas; stretch: match canvas size
sizearrayExplicit display size in canvas pixels; overrides placement

add_folder Add folder

Creates an empty layer folder (group).

ParameterTypeDescription
name *string
path *stringPath to the .comp project package (a directory ending in .comp)
abovestringPlace directly above this layer (id or name)
belowstringPlace directly below this layer (id or name)
parentstringFolder (id or name) to put the layer in; omit for the root

set_layer Set layer properties

Changes name, visibility, opacity, blend mode, mask enablement or transform (origin, size, rotation, flips) of a layer. Only the given fields change.

ParameterTypeDescription
layer *stringLayer UUID or its exact name
path *stringPath to the .comp project package (a directory ending in .comp)
activebooleanMake it the selected layer in Compositor
blendModestring
flipXboolean
flipYboolean
maskEnabledboolean
namestring
opacitynumber
originarrayTop-left in canvas pixels
rotationnumberClockwise degrees
samplingstring
sizearrayDisplay size in canvas pixels; source pixels are untouched
visibleboolean

move_layer Move layer in the stack

Reorders a layer (with its subtree if it is a folder): to the top or bottom of a folder or the root, or directly above/below another layer.

ParameterTypeDescription
layer *stringLayer UUID or its exact name
path *stringPath to the .comp project package (a directory ending in .comp)
abovestringPlace directly above this layer (id or name)
belowstringPlace directly below this layer (id or name)
parentstringFolder (id or name) to put the layer in; omit for the root
tostringTop or bottom of the destination folder (or root)

remove_layer Remove layer

Deletes a layer (and, for a folder, everything inside it) together with its image and mask files.

ParameterTypeDescription
layer *stringLayer UUID or its exact name
path *stringPath to the .comp project package (a directory ending in .comp)

replace_layer_image Replace layer pixels

Swaps the source pixels of a pixel layer with another image file, keeping its transform, mask and properties. Use it to round-trip a layer through an external editor or a generated image.

ParameterTypeDescription
imagePath *string
layer *stringLayer UUID or its exact name
path *stringPath to the .comp project package (a directory ending in .comp)
keepDisplaySizebooleantrue keeps the on-canvas size; false shows the new image 1:1

set_layer_mask Set or clear a layer mask

Attaches a raster mask from a grayscale image (white reveals, black hides) to a layer, or removes the existing mask. The mask is stretched over the layer's own rectangle.

ParameterTypeDescription
layer *stringLayer UUID or its exact name
path *stringPath to the .comp project package (a directory ending in .comp)
invertboolean
maskPathstringGrayscale or any image; luminance becomes coverage. Omit to clear the mask.

resize_canvas Resize canvas

Changes the document size without resampling layers. Layers keep their pixels and are offset according to the anchor.

ParameterTypeDescription
height *integer
path *stringPath to the .comp project package (a directory ending in .comp)
width *integer
anchorstring

open_in_compositor Open in Compositor

Opens (or reloads) the project in the Compositor app on this Mac so the user can see the result. Compositor reads the package from disk on open.

ParameterTypeDescription
path *stringPath to the .comp project package (a directory ending in .comp)