Nodes/ComfyUi-MpiNodes/Mpi From Box
ComfyUI Node

Mpi From Box

Unpack an MPI_BOX back into plain integers

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi From Box
  • mpi_box
  • width
  • height
  • x
  • y

The MPI_BOX wire type is this pack's answer to "stop routing four loose integers everywhere." One node (MpiBox) builds a rectangle - width, height, x, y - and bundles it onto a single wire that any box-aware node can consume. MpiFromBox is the other half of the contract: it takes an MPI_BOX and unpacks it back into width, height, x, y as plain INTs. It's the escape hatch for the moment you want box data in a node that doesn't speak MPI_BOX.

How it works

One input, mpi_box, and four INT outputs: width, height, x, y. Under the hood a box is just a tuple (x, y, w, h), where x/y are the top-left corner - the same convention ComfyUI's core BOUNDING_BOX uses. The node literally unpacks that tuple and hands each element out on its own socket. Nothing is transformed, clamped or validated on the way through; you get exactly the numbers that went in.

Which means its job is purely plumbing. You use it when a node you want to feed - a crop, a mask builder, a custom region consumer - only takes loose INT inputs and won't accept the box wire. Rather than re-derive the rectangle from four separate sources, you route it through MpiFromBox and everything lines up.

The inputs that matter

Just mpi_box, which must come from a box-producing node: MpiBox, MpiBoxCrop, MpiBoxMask, MpiMaskSquareBbox - anything that emits MPI_BOX. There are no widgets to configure; it's a straight decode.

Where people get burned

The x/y convention is the thing to keep straight. x/y are the top-left corner, not the center. If you feed the output into a node that expects center coordinates, your rectangle will land down-and-right of where you meant it. The pack's own box-aware nodes all use top-left, so you're safe as long as you stay inside the family - the trap only appears when you cross into another pack's box type (like ComfyUI core's BOUNDING_BOX primitives, which are also x/y/width/height, so those line up fine, but third-party center-based systems won't).

Also remember this is a pure decode: there's no clamping. A box that overhangs the image comes out with its original (possibly out-of-bounds) values. If you need the safe, clamped version, feed the box through MpiBoxCrop or MpiBoxMask first - both output the clamped box actually used.

Install

From the MadPonyInteractive/ComfyUi-MpiNodes pack. ComfyUI Manager → search ComfyUi-MpiNodes (publisher mad-pony-interactive), install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes

then restart. No dependencies, no models - it's a tuple unpack in node form. The pack is AGPL-3.0 (≤ 1.2.6 MIT) and is the node library behind the author's Cubric Vision app.

The verdict

If you never use MpiBox, you'll never need this - they're a matched pair. But if you adopt boxes (and a rectangle on one wire is a genuinely tidy way to carry crop regions), you'll hit the "but this node wants INTs" wall eventually. That's exactly when MpiFromBox earns its place: the moment you need a box where only numbers are welcome.

CategoryMpiNodes/ImgOps

Inputs (1)

NameTypeDefaultDescription
mpi_boxMPI_BOX

Outputs (4)

NameTypeDescription
widthINT
heightINT
xINT
yINT