Nodes/comfyui-common-util/Added Layer Info To Array
ComfyUI Node

Added Layer Info To Array

Drop one layer at a time into your composite blueprint

By longgui0318·Created 2 years ago·Updated about a year ago· 1
Added Layer Info To Array
  • layerInfoArray
  • layerInfoArray
  • layerInfoArrayJson
type
image
width0
height0
rotation0
position_x0
position_y0

"Added Layer Info To Array" is the "add a layer" step in this pack's layer-compositing system. You start with a blueprint from "Init Layer Info Array", and every time you run one of these it appends one layer to the list: its type, the image file it uses, the size to place it at, its rotation, and where it sits on the canvas.

The mental model is Photoshop layers, described as data. Each layer is a dict - type, image, width, height, rotation, position_x, position_y - pushed onto the blueprint's layers list. Chain several of these together (one per layer, in stacking order) and you've described the whole scene. The later step, "Layer Info Array Fuse", then turns that description into actual composited pixels.

How it works

The mechanism is simple and a little charming: it takes the incoming array, round-trips it through json.dumps/json.loads to get a clean dict, appends the new layer, and returns both the updated typed array and the updated JSON string. Layer order in the list is stacking order - when fused, later layers occlude earlier ones.

Inputs that matter

  • layerInfoArray (LAYER_INFO_ARRAY) - the blueprint from Init (or a previous Add).
  • type - one of Product, Prop, Human-Hand, Human-Male, Human-Female. This drives filtering later ("Layer Image Seleted" and the IPAdapter node filter on it), so it's more than a label.
  • image - a dropdown of files in ComfyUI's input folder. The layer's image must be a real file in ComfyUI/input; the dropdown only lists what's there, and the fuse step opens it by filename.
  • width, height (INT, default 0) - the layer's rendered size on the canvas (it's resized, not cropped).
  • rotation (INT, 0360) - applied with PIL's rotate(expand=True), so the layer's footprint grows when it rotates (a tall image rotated 90° takes up more room).
  • position_x, position_y (INT) - where the layer's top-left corner lands on the canvas. If you want something centered, do that arithmetic yourself - there's no center/alignment mode.

Outputs

  • layerInfoArray - the updated blueprint; feed this into the next "Added Layer Info To Array" or into the fuse node.
  • layerInfoArrayJson (STRING) - the same thing as JSON text.

Where people get tripped up

Position semantics are the classic gotcha: it's top-left paste coordinates, not center-based, so a layer you expect to be centered will sit in the corner if you set position to the canvas size divided by two minus the layer size. And remember the input-folder rule - images added to the dropdown after ComfyUI starts need a refresh (or a restart) to show up. Rotation expanding the layer's footprint is the other surprise: a rotated layer can overhang its intended spot, which is usually fine (paste just clips), but it means rotation and size interact.

Installing it

Part of longgui0318/comfyui-common-util:

cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-common-util
cd comfyui-common-util && pip install -r requirements.txt

Restart after, or install via ComfyUI Manager by searching "comfyui-common-util". requirements.txt pins only opencv-python, but the pack imports scipy, scikit-image, and PyWavelets at load - if it won't load, pip install scipy scikit-image PyWavelets and restart.

Categoryutils

Inputs (8)

NameTypeDefaultDescription
layerInfoArrayLAYER_INFO_ARRAY
typeCOMBO5 options: Product, Prop, Human-Hand, Human-Male, Human-Female
imageCOMBO1 options: example.png
widthINT0
heightINT0
rotationINT00–360
position_xINT0
position_yINT0

Outputs (2)

NameTypeDescription
layerInfoArrayLAYER_INFO_ARRAY
layerInfoArrayJsonSTRING