Get UV Rect
Freeze a crop box in 0-to-1 coordinates so it survives resizing
- tinyrect
- image
- tinyrect
Here's the problem pixel coordinates have: they're tied to one resolution. A crop box that's perfect at 1024×1024 is wrong at 768, meaningless at 512, and actively misleading after an upscale. Get UV Rect solves it the way game engines and texture artists have for decades - by re-expressing the rectangle in normalized 0-to-1 coordinates where 1.0 means "the full width or height of the image." Your box stops being pixels and becomes a proportion, and proportions survive any resize.
Give it a TINYRECT, tell it the image (or its width and height), and it divides each of x, y, w, h by the image dimensions. A rect at (100, 50, 200, 150) on a 1000×1000 image comes out as (0.1, 0.05, 0.2, 0.15). Apply that same rect to a 512×512 image later and it still points at the same region of the picture. That's the whole magic, and it's the mechanism you want when your pipeline changes resolution between detection and generation - which is every time you do a crop-then-upscale-then-detail loop.
The inputs that matter
tinyrect- requiredTINYRECT, in pixel coordinates.image- optional; if you connect one, the node reads its actual dimensions. This is the convenient path - no math, no guessing.image_w,image_h- optional ints, used only when no image is connected. If you leave both at 0 and don't connect an image, the node raises a clear error: "requires either an image or a positive image_w/image_h." It refuses to guess.
Output is another tinyrect (TINYRECT), now normalized. Where it shines downstream is Rect To Mask in the same pack, which has a uvRect toggle specifically for consuming these: flip it on and the mask comes out at whatever width/height you tell it, with the rect interpreted as fractions. So the pattern is detect → Get UV Rect → (upscale/change canvas) → Rect To Mask with uvRect on, and the mask is automatically right for the new resolution.
Install and gotchas
Part of ComfyUI-TinyBee; install once for all of it:
cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
or ComfyUI Manager → "ComfyUI-TinyBee" → restart. No models, no downloads, no real dependencies - it's a couple of float divisions under the hood. The gotcha is remembering which coordinate space a given rect is in: a 0-to-1 rect fed into a node expecting pixels will silently produce a 1-pixel box in the corner. Keep the convention visible - normalize early, denormalize late - and you'll be fine.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| tinyrect | TINYRECT | — | |
| imageopt | IMAGE | — | |
| image_wopt | INT | 00–100000 | — |
| image_hopt | INT | 00–100000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| tinyrect | TINYRECT | — |