# LayersFromBoundingBoxes

This node converts an image batch and its bounding boxes into a layer stack, creating one layer per frame and placing each layer according to its matching box. Use it when a node outputs layers as a batch, because a batch carries only a single placement for every frame and the individual positions would otherwise be lost.

## Inputs

| Parameter | Description | Data Type | Required | Range |
|-----------|-------------|-----------|----------|-------|
| `image` | Image batch; each frame becomes one layer. | IMAGE | Yes | — |
| `bboxes` | Placement boxes, index-aligned with the image batch. Accepts bounding boxes (x, y, width, height), normalized elements (with a "bbox" — these need canvas_width/canvas_height to resolve to pixels), or a JSON string of either. Frames without a matching box are placed at the origin. A box's width/height scales the layer to fit it. metadata.name (or desc) and metadata.z_index are used when present, and metadata.content_rect (frame-relative) crops the frame to its real content. | BOUNDING_BOX, ARRAY, or STRING | Yes | — |
| `mask` | Per-frame transparency, index-aligned with the image batch (1 = transparent, LoadImage convention). | MASK | No | — |
| `layers` | Layer stack to append to. Leave unconnected to start a new stack. | LAYERS | No | — |
| `crop_to_content` | Crop each frame to metadata.content_rect where present and place the content at the box position plus the rect offset. Leave on for batches whose frames are padded — it keeps only the real content at its true spot. (default: true) | BOOLEAN | No | true<br>false |
| `canvas_width` | Document canvas width. 0 derives it from the placed layers. (default: 0) | INT | No | 0 to MAX_RESOLUTION |
| `canvas_height` | Document canvas height. 0 derives it from the placed layers. (default: 0) | INT | No | 0 to MAX_RESOLUTION |

Notes:

- `bboxes` and `mask` must be index-aligned with `image`: the nth box and the nth mask frame correspond to the nth image frame. Frames without a matching box are placed at the origin.
- When `bboxes` contains normalized elements (with a "bbox"), `canvas_width` and `canvas_height` must be provided so those normalized positions can be resolved to pixels.
- `canvas_width` and `canvas_height` must both be greater than 0 to set the document canvas explicitly. If either is 0, the canvas is derived from the placed layers or inherited from the connected `layers` stack.
- When `layers` is connected, new layers are appended to it and receive z-index values above the highest z-index already present in the stack.
- When `crop_to_content` is enabled and a frame has a metadata.content_rect, the frame is cropped to that rect and the box's width/height scaling is not applied; instead, the rect's offset is added to the box position.

## Outputs

| Output Name | Description | Data Type |
|-------------|-------------|-----------|
| `LAYERS` | The layer stack, ready for Create Layered Image. | LAYERS |

> This documentation was AI-generated. If you find any errors or have suggestions for improvement, please feel free to contribute! [Edit on GitHub](https://github.com/Comfy-Org/embedded-docs/blob/main/comfyui_embedded_docs/docs/LayersFromBoundingBoxes/en.md)

---
**Source fingerprint (SHA-256):** `a70956bf0d7ea8bdbd16767ed8b19600b274a6eeb745728f95219578adc73712`
