Skip to content

compose_image

Stack workspace images into one flat PNG: overlays, backgrounds with a foreground, or collages.

A deterministic file operation: no model runs and no Creative Units are spent. Each layer places
one image in a box on the canvas (by default the size of the first layer's image), positioned by edge anchors and filled by its
resize strategy; layers stack bottom first and blend by their alpha. Parts of the canvas no
layer covers stay transparent.
The image is saved to the workspace library and, when the call runs in a session, placed on
its board (`image.placed_on_board`).

Parameters

ParameterTypeDefaultDescription
widthinteger1–4096—Canvas width in pixels. Omit to use the width of the first layer's image.
heightinteger1–4096—Canvas height in pixels. Omit to use the height of the first layer's image.
layersrequiredComposeImageLayer[]—The layers, bottom first: each later layer is drawn over the earlier ones.
file_idrequiredstring (uuid)—Workspace file id of the image drawn in this layer.
anchorsAnchor—Pixel offsets of the layer box from the canvas edges. Both `left` and `right` set: the box spans between them (omit `width`). One set: the box sits that far from that edge. Neither: the box sits at the left edge. `top`/`bottom` work the same way vertically. To center an image or pin it to a corner without knowing its size, anchor all four sides (0, or the margin) and set the alignments.
topinteger—The top anchor position in pixels.
leftinteger—The left anchor position in pixels.
bottominteger—The bottom anchor position in pixels.
rightinteger—The right anchor position in pixels.
widthinteger1–4096—Layer width in pixels. Required unless both `left` and `right` are anchored.
heightinteger1–4096—Layer height in pixels. Required unless both `top` and `bottom` are anchored.
resize_strategyenumplace_and_cropHow the image fills the layer box: `stretch` distorts to the box; `fit_and_crop` scales to cover the box and crops the overflow (full-bleed backgrounds); `fit_and_pad` scales to fit inside the box and pads with `padding_color` (a logo or character in a box you size); `place_and_crop` keeps native scale and crops what exceeds the box.
One of: stretch, fit_and_crop, fit_and_pad, place_and_crop
horizontal_alignmentenumcenterWhere the image sits inside the layer box horizontally when it is cropped or padded.
One of: left, center, right
vertical_alignmentenumcenterWhere the image sits inside the layer box vertically when it is cropped or padded.
One of: top, center, bottom
padding_colorRGBAColor—Fill for the padded part of the layer box. Transparent by default; `alpha` defaults to 255 when you pass a color.
redinteger0–2550The red component of the color
greeninteger0–2550The green component of the color
blueinteger0–2550The blue component of the color
alphainteger0–255255The alpha component of the color
rotationenum0Turns the image clockwise by this many degrees before it is placed, losslessly; the box, the canvas it sizes and the resize strategy all apply to the turned image. 180 places a playing card's top-left index upside down in the bottom-right corner.
One of: 0, 90, 180, 270
namestring0–120 chars—File name for the composed image.
workspace_idrequiredstring (uuid)—The user's workspace id.
session_idstring (uuid)—Session whose board receives the image. Omit to only save it to the library.
project_idstring (uuid)—Optional project to add the result to; use list_projects to find project ids.