Nodes/ComfyUI-TinyBee/Ints to Rect
ComfyUI Node

Ints to Rect

The Integer Sibling of Floats to Rect

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
Ints to Rect
    • tinyrect
    nanValue-1
    x-1
    y-1
    w-1
    h-1
    x2-1
    y2-1

    Pixel coordinates are integers, full stop. So while Floats to Rect exists for the float-flavored outputs, Ints to Rect is the one you'll probably reach for more often - same constructor, but for the whole-number coordinates that actual image math produces. If you've ever had a detector hand you x, y, width, height as integers and wished you could just stuff them into a rect wire, this is the node.

    How it works

    Identical logic to Floats to Rect, with integers: inputs x, y, w, h and the alternate-corner x2, y2, plus nanValue (default -1) as the "this input is unset" sentinel. Resolution priority:

    • x + w given → use them directly.
    • x + x2 given → width = x2 - x.
    • w + x2 given → x = x2 - w.

    And the same for the vertical axis. Output is a single tinyrect as (x, y, w, h) - the pack's rectangle wire format.

    The one quirk versus the float version: values are cast through int and then to float internally, so the rect you get back is always whole-number-based (the ints become 512.0, not 512.7). That's a feature - you don't want half-pixel rectangles going into image ops that'll silently round anyway.

    Where you'd actually use it

    • Bounding-box plumbing: feed integer boxes from detection or region nodes straight into the pack's rectangle pipeline (Intersect Rects, Rect To Mask, Draw TinyRect, the aspect nodes).
    • Manual layout with exact pixels: type precise coordinates for a crop or inpaint region.
    • Bridging into float math: this outputs a rect, and the pack's Rect to Floats converts back if some float-based node needs the raw numbers.

    Installing it

    Part of ComfyUI-TinyBee under 🐝TinyBee/Rectangles:

    1. ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee" → Install, then restart ComfyUI.
    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    Restart. No models; this node is integer arithmetic and touches nothing in the pack's requirements.txt.

    Gotchas

    The nanValue = -1 sentinel is the same trap as the float version: any input left at the default -1 counts as unset, so you can't represent a rect starting at pixel -1 without changing nanValue first. Practically that's rarely an issue - negative pixel coordinates are usually a sign you're about to feed a rect that needs clamping anyway. And if you leave an axis underspecified, you get 0 dimensions rather than an error, which downstream nodes will quietly accept. If your numbers arrive as floats or strings, cast first - that's the whole reason the pack ships three of these constructor nodes.

    Category🐝TinyBee/Rectangles

    Inputs (7)

    NameTypeDefaultDescription
    nanValueINT-1
    xoptINT-1
    yoptINT-1
    woptINT-1
    hoptINT-1
    x2optINT-1
    y2optINT-1

    Outputs (1)

    NameTypeDescription
    tinyrectTINYRECT