Nodes/tri3d-comfyui-nodes/Scaled paste v5.1.0
ComfyUI Node

Scaled paste v5.1.0

Drop a subject onto a new background at the right scale, bottom-center, no math

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Scaled paste v5.1.0
  • image_background
  • image_foreground
  • mask_foreground
  • IMAGE
scale_factor1.20
height_factor1.01

The classic compositing chore: you've cut a person out, you have a nice new background, and now the person needs to be the right size and standing at the right place. ComfyUI doesn't ship a "just paste it sensibly" node, so this pack's scaled-paste fills the gap. It scales the subject onto the background, positions it bottom-center, and alpha-composites it with the mask. One node, done.

It's built around a simple visual rule: a person should stand on the ground line, centered horizontally, at a natural size relative to the scene. That's what the two factor inputs control, and it's what makes this node feel like a "human paste" rather than a generic composite.

How it works

The mechanism is cleverer than it looks. Rather than just resizing the subject to a fixed fraction, it computes how much the background must be scaled so the subject fits comfortably - it takes the max of the background height vs. the subject's scaled height, and the background width vs. the subject's width, and sizes the background up by scale_factor on top of that. The background is resized (cubic interpolation) to fit the subject's footprint, then:

  • Vertically: the subject's bottom lands at the bottom of the background (with a height_factor nudge that lifts it), so feet touch the ground line.
  • Horizontally: centered.

Finally the mask-weighted blend pastes the subject in: result = mask * foreground + (1 - mask) * background, per channel.

The inputs that matter

  • image_background (IMAGE) - the scene.
  • image_foreground (IMAGE) - the cutout subject.
  • mask_foreground (MASK) - the subject's alpha/mask.
  • scale_factor (FLOAT, 1–10, default 1.2) - how much larger the subject should appear. 1.2 means "a bit of breathing room."
  • height_factor (FLOAT, 1–8, default 1.01) - relative vertical position; values above 1 place the subject higher relative to the ground line.

Output: the composited IMAGE.

Installing it

Same pack:

cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
cd tri3d-comfyui-nodes
pip install -r requirements.txt

or ComfyUI Manager → "tri3d-comfyui-nodes", restart, under TRI3D.

Common issues

  • It rescales the background, not just the subject - the output dimensions change with scale_factor, because the background gets upscaled to make the subject fit. If you need a fixed output resolution, resize afterward. This surprises everyone once.
  • Feet float or sink - height_factor is your vertical-position dial; 1.0 pins the subject's bottom to the background's bottom, higher values raise it. Small increments do a lot.
  • Mask quality is everything - the composite is only as clean as mask_foreground. A rough mask means a rough seam; run the mask through the pack's cleanup nodes first.
  • No shadows - this node pastes flat. If the scene needs the subject to cast a shadow, the pack's simple_bg_swap does that too - it's built on this exact paste, plus a shadow layer.

One more honest note: the node prints a wall of DEBUG lines to the console on every run. Harmless, but it looks alarming the first time. If you want the same paste without the safety scaling - and you're prepared for it to crop the subject - there's an _unsafe variant.

CategoryTRI3D

Inputs (5)

NameTypeDefaultDescription
image_backgroundIMAGE
image_foregroundIMAGE
mask_foregroundMASK
scale_factorFLOAT1.201–10
height_factorFLOAT1.011–8

Outputs (1)

NameTypeDescription
IMAGEIMAGE