Nodes/MTB Nodes/Crop (mtb)
ComfyUI Node Runs on cloud

Crop (mtb)

Crop an image and mask together, by coordinates or a wired BBOX

By melMass·Created 3 years ago·Updated about a month ago· 721
Crop (mtb)
  • image
  • mask
  • bbox
  • IMAGE
  • MASK
  • BBOX
x0
y0
width256
height256

Crop is one of MTB Nodes' oldest and plainest utilities, and it's a good example of what this pack is at its core: small, general-purpose image operations that core ComfyUI doesn't ship on its own. It crops an image - and, if you give it one, a mask alongside it - to a bounding box, and hands the box itself back out so you can reverse the operation later.

Two ways to give it a crop region

Straight from the node's own description: the bounding box can be given either as loose x, y, width, height widgets, or as a wired BBOX input, and the BBOX input takes precedence if both are present. That matters in practice - if you're feeding this node a BBOX from a detector upstream (a face-detection node, say, or MTB's own BBox Force Dimensions) but also have leftover widget values from earlier testing, the wired BBOX wins silently. Know which mode you're actually in before debugging an unexpected crop region.

The inputs and outputs that matter

  • image (required) - the source to crop.
  • mask (optional) - cropped in lockstep with the image if you provide one, so image and mask stay aligned.
  • x, y, width, height (optional, defaults 0, 0, 256, 256) - the manual crop rectangle. The widget max is a huge 10,000,000, which in practice just means the widget places no real ceiling on you - normal image dimensions are nowhere near that limit.
  • bbox (optional) - a wired BBOX, overriding the manual coordinates above when present.

It returns three things: IMAGE (the cropped image), MASK (the cropped mask, if one was given), and BBOX - the actual box that was used for the crop. That last output is easy to overlook but genuinely useful: keep it around and you can composite the cropped, processed result back into the exact original position later with an uncrop-style node, without re-deriving the coordinates by hand.

Installing it

ComfyUI Manager: search MTB Nodes, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb

then restart ComfyUI. No models, no extra dependencies - this is tensor slicing.

Common issues

The precedence rule above is the one thing that actually confuses people: set your x/y/width/height widgets, get a crop that doesn't match them, and the reason is almost always a BBOX still wired in from earlier in the graph taking priority. Disconnect it if you want the manual widgets to actually apply.

Beyond that, the pack-wide caveat: MTB logs [comfy_mtb] Some nodes (N) could not be loaded at startup instead of crashing when a node fails to import, with a pointer to http://127.0.0.1:8188/mtb for the real cause - confirmed by other users' actual install logs. If Crop doesn't show up after installing, check that line before reinstalling.

Categorymtb/crop

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
maskoptMASK
xoptINT00–10000000
yoptINT00–10000000
widthoptINT2560–10000000
heightoptINT2560–10000000
bboxoptBBOX

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
BBOXBBOX