Nodes/Link Comfy Nodes/Align Frames to Root
ComfyUI Node

Align Frames to Root

The node that stops your character changing size between animations

By Mister-Link·Created 10 months ago·Updated 2 days ago· 0
Align Frames to Root
  • root_frame
  • frames
  • aligned_root
  • aligned_frames
match_axisHeight (Y)
scaling_modePrecise

You've done it. Two WAN clips of the same character, both good on their own, and the instant you cut from the standing idle to the jump-start the character visibly shrinks and slides six pixels left. Same LoRA, same prompt, different footprint. That jarring size-and-position hop is the "cross-clip consistency" problem nobody solved at the model level - every generation is independent - and Align Frames to Root is the after-the-fact fix for its geometric half.

It takes one reference image (the "root") and a batch of frames, then warps the batch so the subject's scale and placement match the root. Not the face, not the pose - the footprint. One shared transform is estimated from the root and the first frame of your batch, then applied to every frame, so whatever internal motion the clip has stays intact while the whole thing locks onto the root's ground position and height.

The name oversells slightly: this is scale and translation only. No rotation, no shear, and it deliberately won't contort frames to fit a pose. What it does do is find the subject - using the alpha channel if you feed transparent sprites, otherwise by segmenting against the color sampled from the image corners - grab the biggest connected region, scale its bounding box to the root's, then run a small local refinement pass against the two silhouettes to fix a pixel or two of drift. If the first frame is already a close silhouette match, great, it tightens; if not, it falls back to the bounding-box alignment, which is the more stable anchor anyway.

The inputs that matter

Only four, and you mostly touch two:

  • root_frame - your reference. The author calls it the animation's "home position". Pick the pose every other animation should be judged against.
  • frames - the batch to align. The correction comes from its first frame.
  • match_axis - Height (Y) (default) pins top edges and centers horizontally, which is what you want for a standing character; Width (X) pins left edges and centers vertically instead.
  • scaling_mode - Precise (default) scales X and Y independently to fill the root's subject bounds, which can distort aspect ratio; Proportional applies one scale to both dimensions so proportions survive.

Outputs are aligned_root and aligned_frames, both IMAGE - and here's the gotcha: they share a brand-new canvas sized to fit the root plus every aligned frame with 8px of breathing room. The root is not rescaled, just moved onto that canvas, so grab both outputs or the root will look wrong in isolation. Expect the resolution to change, with the gutters filled in the corner background color, or transparent if you fed it RGBA sprites.

When you'd actually reach for it

Whenever independent generations of one character need to live in the same world: lining up separate animations before you loop or cut between them, pre-tidying frames that are about to feed a pose-driven or VACE workflow, or building game-style sprite assets where the character must occupy the same box in every pose. It slots in as a pure image transform - frames in, frames out - so it works wherever a batch of IMAGE flows.

Where people get burned: a busy background with no consistent corner color (it can't find the subject and raises a "could not detect foreground" error), and clips where the first frame's pose is radically different from the root's - you'll get bbox-level alignment and a bigger canvas than you wanted. Keep it to same-character, clean-background work and it's quietly excellent.

Installing it

Part of Link Comfy Nodes by Mister-Link, whose README is exactly one line: "AI slop nodes for my own purposes, use at your own risk (I change how nodes behave without warning)." Take that seriously - it's a personal pack and updates can move things.

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes

…or install it from ComfyUI Manager by searching Link Comfy Nodes, then restart ComfyUI. This node itself only needs OpenCV on top of what ComfyUI ships (cv2 is imported at pack load, so the pack won't register if it's missing), but the pack's requirements.txt pulls in a lot more - transformers, numba, pytorch_lightning, a CLIP git install - all for sibling nodes you may never touch. No model files download for this one.

Categoryimage/transform

Inputs (4)

NameTypeDefaultDescription
root_frameIMAGEThis reference image aligns every frame in the animation, preventing noticeable position and scale differences between animations—for example, between a standing idle and a jump-start animation. Choose a root frame that represents the animation’s intended ‘home position’.
framesIMAGEFrame batch to align. The correction is estimated from its first frame and applied to every frame.
match_axisCOMBOHeight (Y)In proportional mode, this dimension determines the shared scale. Height (Y) anchors their top edges and centers them on X; Width (X) anchors their left edges and centers them on Y.
scaling_modeCOMBOPrecisePrecise scales X and Y independently to match the root subject bounds. Proportional applies the selected match-axis scale to both dimensions to preserve the frame's aspect ratio.

Outputs (2)

NameTypeDescription
aligned_rootIMAGE
aligned_framesIMAGE