BBox Force Dimensions (mtb)
Pin a detected crop box to a fixed size
- bbox
- image
- BBOX
Face detectors, segmentation nodes, and anything else that hands you a bounding box will give you whatever size actually fits the detected region - a tight box around a face that's 340×290 in one frame and 410×355 in the next. That's a problem the moment you need consistent input dimensions downstream: a fixed-resolution restoration model, a batch where every crop needs to line up, a composite where the crop size can't vary frame to frame. BBox Force Dimensions solves exactly that: it resizes a BBOX to an exact width and height while keeping it centered on the same point - straight from the pack's own description.
Where it fits
You'll almost always find this sitting between a detector (face detection, a segmentation node, anything that outputs BBOX) and a crop node like MTB's own Crop. Detector finds the region loosely, this node pins it to the size your pipeline actually needs, then Crop (or an equivalent) does the cutting.
The inputs and output that matter
bbox(BBOX, required) - the box to resize, typically straight from a detector node.width/height(default 512 each, 1–8192) - the exact output dimensions you want the box forced to.constrain_to_image(defaulttrue) - clamps the resized box so it doesn't run off the edges of the source image. This needs the optionalimageinput to know where those edges are; without it wired in, there's nothing to constrain against, so the box could extend past the actual frame.
Output is a single BBOX - same type it took in, just resized. Feed it straight into a crop node next.
Installing it
ComfyUI Manager: search MTB Nodes, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb
then restart ComfyUI. No models involved - this is pure geometry.
Common issues
If you leave constrain_to_image on (the default, sensibly) but forget to wire in the optional image input, the constraint has no bounds to clamp against - so a detected box near the edge of the frame can still end up requesting a region that extends past the actual image once forced to your target size. Wire the source image in whenever the box you're resizing came from something near an edge (a face turned toward the frame border is the classic case).
Also worth remembering: forcing dimensions can change the box's aspect ratio from whatever the detector originally found, which for a face crop especially means some background gets pulled in around the sides, or the crop gets a little tighter than you'd expect - that's inherent to forcing a fixed size onto an arbitrary detected region, not a bug.
The pack-wide behavior applies here too: MTB logs [comfy_mtb] Some nodes (N) could not be loaded at startup instead of crashing outright, with a pointer to http://127.0.0.1:8188/mtb for the actual cause - a real, confirmed pattern from other users' install logs. Check that line first if this node is missing after install.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| bbox | BBOX | — | |
| width | INT | 5121–8192 | — |
| height | INT | 5121–8192 | — |
| constrain_to_image | BOOLEAN | true | — |
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BBOX | BBOX | — |