Nodes/Duanyll Nodepack/Bounding Box Crop
ComfyUI Node

Bounding Box Crop

Cut the Detected Region Out, Exactly Where the Box Says

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Bounding Box Crop
  • image
  • bbox
  • IMAGE

BBoxCrop is the pay-off node of the bbox toolkit: take the rectangle you found (from a mask, from a vision model, from an anchor) and cut it out of the image. Feed it an IMAGE and a BBOX, get back the region inside the box as a fresh, smaller IMAGE.

It's the node you reach for when a detection has found something worth looking at up close - a face crop for further analysis, a tight region to re-run through a detailer, or a way to isolate an object so the rest of the workflow doesn't have to carry the whole canvas.

How it works

Mechanically it's a tensor slice: the bbox coordinates are clamped to the image bounds, then image[:, y_min:y_max, x_min:x_max] - one clean crop, preserving the batch dimension. No resizing, no padding, no interpolation. What you get is exactly the pixels inside the box, at original resolution.

Two behaviors to know. First, if the box is entirely outside the image or collapses to zero area, it raises a clear "Invalid bounding box coordinates" error rather than returning garbage - a crash you can actually debug. Second, out-of-bounds boxes are clipped rather than rejected, so a box that hangs off the edge still produces a usable partial crop.

Inputs and outputs

  • image - the source IMAGE.
  • bbox - the pack's BBOX (from MaskToBBox, ParseBBoxQwenVL, ExpandBBoxByRatio, etc.).

Output is the cropped IMAGE. Same channel layout, smaller spatial size.

Where it fits

The classic chain: MaskToBBoxExpandBBoxByRatio (loosen the crop so it isn't skull-tight) → BBoxCrop → whatever needs the isolated region. It also composes naturally with the pack's stitcher if you crop a bunch of tiles and later want them reassembled with per-tile boxes.

Installing it

Part of Duanyll Nodepack:

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack

or install "Duanyll Nodepack" via ComfyUI Manager and restart. Pure tensor slicing - no models, no downloads.

Gotchas

Keep the resolution reality in mind: a crop doesn't add detail. A 24×24 face box cut from a 512² image is a 24×24 image, and upscaling it later won't invent pixels that were never captured - if you're cropping before detail work, expand the box first (ExpandBBoxByRatio exists precisely for that). Also remember it's a straight cut, so aspect-ratio-critical downstream steps (like a face model expecting squares) will need a resize after the crop. And if you see the "Invalid bounding box coordinates" error, it's almost always a zero-area box - expand it and retry.

Categoryduanyll/bbox

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
bboxBBOX

Outputs (1)

NameTypeDescription
IMAGEIMAGE