Nodes/ComfyUI-TextureAlchemy/Crop (from Bbox Data) ⚡
ComfyUI Node

Crop (from Bbox Data) ⚡

Feeding a bounding box back into an image

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Crop (from Bbox Data) ⚡
  • image
  • bbox_data
  • mask
  • cropped_image
  • cropped_mask
  • bbox_data
  • info

Bounding boxes are the connective tissue of a lot of ComfyUI workflows - detection nodes hand you a box, you do something inside that box, then paste it back. This node is the "crop to that box" half of the loop. You feed it an image plus a BBOX_DATA structure and it cuts out the region, along with an optional matching crop of the mask. If you've ever built an inpainting or object-editing chain, you already know why this matters: you crop tight to the subject, run the expensive per-region work, then composite back using the same box.

The name says the clever part: it crops from bbox data, not from a mask. The BBOX_DATA type is the pack's own - you get it from nodes like Crop to Mask (with Padding) or any other TextureAlchemy node that emits one - but it's just a dictionary carrying x, y, width, height, plus original_width and original_height. The node reads that box in "original" coordinate space and crops.

That last bit is where it earns its keep. Because the bbox is tagged with the original dimensions, you can resize the image after the box was created and the node will scale the box to match before cropping. Resized your 2048 texture down to 1024 to run it through an upscaler, and now the box doesn't fit? No problem - it recomputes the coordinates, clamps to the image bounds, and crops anyway. If the box is entirely out of range it falls back to the full image and tells you in the console instead of erroring out. That's the kind of defensive behavior that makes a workflow survive edits.

Inputs:

  • image - the image to crop
  • bbox_data - the box, from a BBOX_DATA output
  • mask - optional; if given, you get a cropped mask back

Outputs: cropped_image, cropped_mask, bbox_data (the new box, re-expressed relative to the crop), and info - a STRING with the resulting crop dimensions that's handy for logging or wiring into a text display.

Where it slots in: the pack's own crop node produces a bbox_data output precisely so you can hand it to this node later. A typical flow is Crop to Mask (with Padding) → work on the cropped region → use the saved bbox to know exactly where things sat. It also plays fine with other packs that speak bbox-ish formats, since the underlying data is just coordinates.

Install: ComfyUI Manager → search "Texture Alchemy", or clone manually:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart, then Texture Alchemist/Inpainting → Crop (from Bbox Data). No dependencies beyond ComfyUI's bundled PyTorch. The shared pack gotchas apply: the README's manual-copy step references the old ComfyUI_PBR_MaterialProcessor folder name, and if Manager blocks a Git-URL install, that's ComfyUI's security level - clone by hand instead of weakening it.

CategoryTexture Alchemist/Inpainting

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
bbox_dataBBOX_DATA
maskoptMASK

Outputs (4)

NameTypeDescription
cropped_imageIMAGE
cropped_maskMASK
bbox_dataBBOX_DATA
infoSTRING