LTXV Resize Reference By Mask
Scale a reference object to match a target's mask, not just its frame
- ref_image
- size_mask
- ref_mask
- image
- object_mask
Normal image resizing scales to fit a canvas. This node scales to fit a mask's bounding box instead - it takes your ref_image, works out the target object size from size_mask, and rebuilds the reference at that scale onto a clean canvas. The use case, per the README, is matching a reference's apparent scale to what a guide video or target frame expects before conditioning: if your Edit Anything checkpoint learned "the reference object should be roughly this size relative to the frame," feeding it a reference that's the wrong scale undermines the conditioning even if everything else about it is correct.
What each field controls
ref_image and size_mask are the two required inputs that drive everything - the mask defines the target bounding box, not the reference's own content. fit picks how the reference gets scaled into that box: contain shrinks it to fit entirely inside (may leave background padding), cover scales up to fill the box completely (may crop), stretch distorts the aspect ratio to match exactly. background fills any leftover space with white, neutral_gray, or black - same three options as this pack's LTXVApplyNeutralMask, worth pairing the two so your fill color is consistent across a prep pipeline. padding (default 0, can go negative) nudges the fit tighter or looser inside the target box. hard_edges controls whether the result has a clean or feathered boundary, defaulting on.
There's also an optional ref_mask input - if your reference image itself has meaningful content outside the subject you actually want resized (say, a person on a busy background), pass its mask here so the node knows what to isolate before it resizes, rather than treating the whole reference frame as the object.
Two outputs: image, the resized reference on its clean canvas, and object_mask, the mask of where the (now-resized) object actually landed - useful if a downstream node needs to know the object's new bounding box rather than re-deriving it.
Installing it
Search "ComfyUI-BFSNodes" in ComfyUI Manager, or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/alisson-anjos/ComfyUI-BFSNodes.git
cd ComfyUI-BFSNodes
pip install -r requirements.txt
Restart ComfyUI. Pure image-processing node, no model or LoRA needed - it'll work in any workflow regardless of which Edit Anything checkpoint (if any) you're eventually feeding.
Practical notes
If your final output has the right identity but the wrong proportions - a swapped object that reads as too big or too small for the scene - this is very likely a scale-matching problem this node is built to solve, not a LoRA-strength problem. Get the size_mask right first; it's doing the actual measuring, and a sloppy or oversized mask will hand the node a target box that doesn't reflect where the object is actually supposed to sit. If your reference has background clutter around the subject, don't skip ref_mask - feeding the whole frame in and expecting the node to know what "the object" means is asking it to guess something it has no way to infer from the schema alone.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| ref_image | IMAGE | — | |
| size_mask | MASK | — | |
| fit | COMBO | 3 options: contain, cover, stretch | |
| background | COMBO | 3 options: white, neutral_gray, black | |
| padding | INT | 0-256–256 | — |
| hard_edges | BOOLEAN | true | — |
| ref_maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| object_mask | MASK | — |