ComfyUI Node

Bound Rects

Two detections, one crop box

By TinyBeeman·Created about a year ago·Updated 10 days ago· 1
Bound Rects
  • rectA
  • rectB
  • tinyrect

Detectors hand you rectangles, and rectangles are annoyingly literal: a face box and a body box from the same image don't overlap neatly, and if you want both in one crop you need a box that covers them both. That box is the bounding box of two boxes - the smallest rectangle containing both. Bound Rects computes exactly that, and it's one of those nodes you don't need until you're fifteen nodes deep into a detailing workflow and suddenly you need it constantly.

Mechanically it's a union: take two rects, keep the minimum x, minimum y, then the maximum right edge and maximum bottom edge, and emit that as a new rect. If you're running the detect-mask-inpaint loop that drives most automated detailing - the "all detailers do is zoom in on a mask" pattern from the masking-detection docs - this is the node that merges a face bbox and a hand bbox into one region so a single inpaint pass fixes both instead of two separate crops with a seam between them.

The inputs and outputs that matter

  • rectA, rectB - two TINYRECT inputs (the pack's rectangle type: an (x, y, w, h) tuple of floats). Order doesn't matter; the union is symmetric.
  • tinyrect - the output TINYRECT covering both, which wires straight into TinyBee's crop, mask, and aspect nodes.

One behavior worth knowing: the node treats a rect with zero or negative width or height as "empty," and it's forgiving about it. Both empty → you get a degenerate (0, 0, 0, 0) rect. One empty → you get the other one back untouched. That's a genuinely useful safety valve when a detector comes up empty on one branch and you don't want the whole union to collapse into nothing.

TINYRECT, briefly

Since this is a rect-family node, you'll be living with the TINYRECT type. It's this pack's own socket type - (x, y, w, h) as floats, in pixel coordinates by default - and it only connects to other TinyBee nodes (and anything else that declares the same type string). You'll typically get a TINYRECT out of a detector-parsing node like Florence2 Caption Data Parser, shape it with this and the other rect nodes, and feed the result to a crop or mask node.

Install and gotchas

Everything TinyBee installs as one pack:

cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee

or via ComfyUI Manager, searching "ComfyUI-TinyBee", then restart. No models, no heavy deps - just the pack's light pillow/jsonata requirements.txt, and this node uses neither. The one thing to keep straight: this computes a union. If you wanted the overlap (what two rects share), that's Intersect Rects in the same pack - grab the wrong one and your crops get mysteriously huge or mysteriously tiny. Union and intersection both live in the 🐝TinyBee/Rectangles category, right next to Get UV Rect, Scale Rect, and the rest.

Category🐝TinyBee/Rectangles

Inputs (2)

NameTypeDefaultDescription
rectATINYRECT
rectBTINYRECT

Outputs (1)

NameTypeDescription
tinyrectTINYRECT