Layer Align
Put a layer where you mean it, by naming a corner
- layers
- layers
- x
- y
In the WAS Node Suite's layer system, a LAYERS document is a Photoshop-style stack passed down the wire - each layer carrying a picture, position, size, angle and blend mode, and a compositor node like Create Layered Image rendering the lot. Once you're building compositions out of layers, you hit the boring problem immediately: putting a layer where you want it means knowing its own dimensions and the canvas's, and doing that arithmetic by hand is exactly the sort of thing that should be a button. WAS Layer Align is that button - you name a corner and it puts the layer there.
You pick how the layer sits with align, which is a plain-English anchor: middle center centres it, bottom right puts its bottom right corner on the target's, and so on across the full set of corners and edges. Then scope decides who moves - one layer moves the single layer that index or layer_name picks (index counts 0 from the back, -1 is the front), while every layer moves them all to the same anchor, which is how you'd stack a set of crops neatly into one spot.
The clever part of this node is what it aligns against, in against. the canvas is the obvious one - the document's own size. But another layer aligns the moving layer against the box that another layer draws in, chosen by target_index or target_name. That's how you centre a caption over a specific graphic rather than over the whole page, or line a badge up with a subject that isn't in the middle of the canvas. And because alignment is measured against the box a layer actually draws in, a rotated title still sits flush - the tooltip makes the point directly: "a turned layer is aligned by the box it actually draws in, so a rotated title still sits flush." No manual trig because you rotated something earlier in the chain.
offset_x and offset_y nudge after the anchor does its job - the sign flips depending on which side you're on, so +24 pushes 24px in from a left edge while -24 is what pushes 24px in from a right one. Offsets are how "flush to the edge" becomes "flush with a 24px margin" without inventing a whole second alignment vocabulary.
Outputs: the stack with the layers moved (layers, for Create Layered Image or the next edit), plus x and y - where the last layer moved landed, as its left and top edges in pixels. Those two numbers are worth wiring somewhere when you need the position for something else, like drawing a matching shadow that has to follow the layer exactly.
Where this fits in a workflow: the layer tools elsewhere in the suite (Layer Edit, Layer Fit, the effects) all end up moving things around, and Layer Align is the one that removes the coordinate guesswork from that whole class of job. If you've ever measured a canvas, measured a layer, and subtracted to centre something, this is the node that deletes those three steps.
Install
Part of WAS Node Suite v3 - ComfyUI Manager, search "WAS Node Suite", or:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui
Restart after. Needs ComfyUI 0.14.0+ and Python 3.10+. The layer system is pure node-side bookkeeping - no pip packages, no model downloads (v3 dropped the old pack's dependency load entirely).
Common issues
- Layer lands on the wrong edge. Check the sign conventions in
offset_x/offset_y- right-side edges take negative offsets to push inward. - Centring against the wrong thing.
againstdefaults tothe canvas. If you wanted it over another layer, switch toanother layerand set the target. - Everything moved when you meant one.
scopeis onevery layer. Set it toone layerand useindexorlayer_name.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| layers | LAYERS | The stack holding the layer to move. Wire in Add Layer, Layer Edit or anything else answering a LAYERS document. | |
| align | COMBO | middle center | Where the layer sits inside what it is aligned against. `middle center` centres it, `bottom right` puts its bottom right corner on the target's. |
| scope | COMBO | How many layers move. `one layer` moves the one index or layer_name picks; `every layer` moves them all to the same anchor, which stacks a set of crops into one spot. | |
| index | INT | -1-16384–16384 | Which layer moves, counting 0 from the back of the stack. -1 is the front layer. Ignored while layer_name names one, or on `every layer`. |
| layer_name | STRING | Name of the layer to move instead of index. Blank uses index. 'sky' finds a layer called Sky, and finds Sky Backdrop where nothing is called exactly Sky. | |
| against | COMBO | What the layer is aligned inside. `the canvas` is the document's own size, or the box its layers reach where it names none; `another layer` is the box the layer target_index or target_name draws in. | |
| target_index | INT | 0-16384–16384 | Which layer is aligned against on `another layer`, counting 0 from the back. 0 is the back layer, which is usually the plate. |
| target_name | STRING | Name of the layer to align against instead of target_index. Blank uses target_index. Read only on `another layer`. | |
| offset_x | INT | 0-16384–16384 | Pixels added right of where the anchor put it. 0 = flush, 24 = 24px in from a left edge, -24 = 24px in from a right one. |
| offset_y | INT | 0-16384–16384 | Pixels added below where the anchor put it. 0 = flush, 24 = 24px down from a top edge, -24 = 24px up from a bottom one. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| layers | LAYERS | The stack with the layers moved, for Create Layered Image or another edit. |
| x | INT | Where the last layer moved landed, as its left edge in pixels. |
| y | INT | Where the last layer moved landed, as its top edge in pixels. |