Scale Rect
Scale a bounding box without breaking your head
- tinyrect
- tinyrect
Bounding-box work is where ComfyUI either clicks or makes you want to close the laptop. A rect is just four numbers - x, y, width, height - but the moment you scale one naively, the box slides sideways and whatever mask you were about to draw is suddenly in the wrong place. Scale Rect is TinyBee's answer: it scales a rectangle for you and keeps the geometry consistent.
It lives in the pack's 🐝TinyBee/Rectangles category, a family that also includes Rect To Mask, Draw TinyRect, Rect Inside Image, and friends. If you're doing regional work - cropping to a detected box, growing a face region before inpainting, rescaling a bbox before it hits a mask node - this is the transform step you slot in the middle.
How it works
You feed in one tinyrect plus two floats: xScale and yScale, both defaulting to 1.0 with a 0.01 step. The math is simple:
- x and width get multiplied by
xScale - y and height get multiplied by
yScale
Values above 1 grow the box, below 1 shrink it, and 1.0 is a no-op - handy for keeping a workflow parameterized and just leaving the scale at identity. Because the position scales along with the size, the rectangle expands outward from its top-left origin rather than staying centered. That's usually what you want when the corner is the anchor (crop regions, tiled grids). If you were expecting it to grow around its center, that's the one thing to watch - by default it's origin-anchored.
The output is another tinyrect with the same type, so it drops straight into any other TinyBee rect node or any workflow already wired for TINYRECT.
Where you'd actually use it
The classic case is inpainting or upscaling a region: detect a subject's box, run it through Scale Rect at, say, xScale 1.3 / yScale 1.3 to add padding, then hand the grown box to a Rect To Mask so your inpaint only fires where you want it. You also see it in animation/latent workflows where a box from one resolution needs to be re-proportioned for another.
Install
It ships in the ComfyUI-TinyBee pack. Easiest path is ComfyUI Manager - search for ComfyUI-TinyBee and install. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
Then restart ComfyUI. The rect nodes themselves are pure Python stdlib, so no extra model downloads or heavy dependencies. The pack's requirements file lists pillow and jsonata, but those back the image and JSON nodes elsewhere in the pack - not this one.
Gotchas
The two classic misses: forgetting that position scales too (a 1.5× scale moves the corner outward as well as growing the box), and leaving both scales at 1.0 while wondering why nothing changed. Both are "working as intended." Also note that scaling is done in the rect's own coordinate space - if your workflow later converts the rect to pixels for a different resolution, do that conversion after scaling, not before.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| tinyrect | TINYRECT | — | |
| mode | COMBO | scaleFromOrigin | 3 options: scaleFromOrigin, scaleFromUV, scaleFromAbsolute |
| xScale | FLOAT | 1.00 | — |
| yScale | FLOAT | 1.00 | — |
| uvCenterX | FLOAT | 0.50 | — |
| uvCenterY | FLOAT | 0.50 | — |
| absCenterX | FLOAT | 0.00 | — |
| absCenterY | FLOAT | 0.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| tinyrect | TINYRECT | — |