ComfyUI Node

BBOX Resize

Fit a Bounding Box to Any Canvas (Without Stretching It)

By metncelik·Created 2 years ago·Updated about a year ago· 2
BBOX Resize
  • bbox
  • bbox
  • new_width
  • new_height
width512
height512
keep_ratiotrue

A bounding box tells a ComfyUI node where something is: x_min, y_min, width, height. The catch is that the box usually comes from a detector that ran on one image size, and the thing you actually want to do with it - a detail pass, an inpaint, a paste-back - happens on a different size. BBOX Resize exists to bridge that gap. Give it a box and a target width/height, and it hands you back a box that fits inside that target the way a photo fits in a frame: the whole shape preserved, nothing stretched.

The trick is keep_ratio, which defaults to on. Rather than jamming the box into the target dimensions, the node works out the box's own aspect ratio and scales it so it fits within the target - the same "contain" behavior you know from CSS. A 4:3 box resized into a 512×512 target comes back 4:3, sitting at 512×384 (or 384×512, depending on orientation), with the origin scaled along with it. Turn keep_ratio off and it just adopts the target numbers wholesale. One honest warning about that mode: it does not re-anchor the origin. The returned box keeps its old x_min/y_min while its size jumps to whatever you typed, so unless you know the box is already where you want it, keep the ratio on and let the node move the origin with the box.

The BBOX type this pack uses is the one Impact Pack made standard - the same type that falls out of its Ultralytics, SAM and ONNX detectors. So the natural chain is: detector → BBOX Resize → FaceDetailer, or a grounding box from a vision-language model scaled up to your canvas before you build a mask. That text-grounded masking pattern (point a VLM at an image, take its box, turn it into a mask) is the low-effort way to skip hand-painting masks in 2026, and this node is the sizing step that keeps those workflows honest.

Inputs that matter: bbox, width/height (both default 512), and keep_ratio. Pass 0 for either dimension and it keeps that side's original length instead - handy when you only want to fix one axis. It outputs the resized bbox plus new_width and new_height as plain INTs, which are more useful than they look: wire them straight into a canvas or latent-size node so everything downstream is guaranteed to match.

Where people get burned: with keep_ratio on, the scaled x_min/y_min come out as floats, not integers. Most BBOX consumers don't care, but if you're feeding the numbers into math nodes that expect ints, floor them yourself.

Install is shared across the whole comfyui_met_suite family. Easiest: ComfyUI Manager → search comfyui_met_suite → install → restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/metncelik/comfyui_met_suite

Then restart ComfyUI. That's the whole install: the pack's only declared dependency is Pillow, which ComfyUI already ships, and there are no model downloads or API keys anywhere. If a workflow wants more than BBOX Resize, BBOX Padding and Primitive BBOX are the rest of this small, focused family.

CategoryMET SUITE/bbox

Inputs (4)

NameTypeDefaultDescription
bboxBBOX
widthINT512
heightINT512
keep_ratioBOOLEANtrue

Outputs (3)

NameTypeDescription
bboxBBOX
new_widthINT
new_heightINT