Nodes/comfyui-mudknight-utils/BBox Inset and Crop
ComfyUI Node

BBox Inset and Crop

The small helper that trims detailer crops before they're composited

By mudknight·Created 8 months ago·Updated 2 months ago· 1
BBox Inset and Crop
  • crop_image
  • bbox
  • cropped_image
  • inset_bbox
inset_pixels8

Not every node is a headline act. BBox Inset and Crop is the kind of utility that lives inside a larger pipeline and quietly makes it work: its own description says "used internally in detailer nodes for cropping from bbox." If you're building your own detect-crop-detail workflow rather than using the pack's one-node detailers, this is the bit that handles a fiddly problem - cropping right up to a detected bounding box leaves sampling artifacts at the edges, and inset is how you trim them.

The mechanism is straightforward. You feed it a crop_image (already cropped to a detected region), a bbox (the bounding box in the original image's coordinates, as produced by an Impact Pack detector), and inset_pixels (default 8). It shrinks the box inward by that many pixels on each side - capped so it never collapses the box, and never to below 8×8 pixels so the result stays VAE-friendly - and then crops those same inset edges off the image. What you get back is a cropped_image with the noisy outer ring of the detection removed, plus the inset_bbox telling you where that smaller region sits in the original frame, so you can composite the result back accurately.

The inputs

  • crop_image - the region you detected, already cropped.
  • bbox - the bounding box, in original-image coordinates. This node expects the Impact Pack BBOX format (x, y, width, height), and it handles the nested-tuple shape those nodes sometimes emit.
  • inset_pixels - how far to trim from each edge. The default 8 is a sensible "shave the artifacts" value; go higher when your detector is sloppy, lower when the region is small.

Outputs: cropped_image and inset_bbox.

Why you'd use it at all

If you're chaining a custom detailer, this is the difference between compositing a crop with a hard, artifact-ridden edge and one that blends cleanly. It's also a genuinely educational node - read its ~40 lines of source and you'll understand the exact coordinate math every detailer in this pack does internally (the mudknight FastDetailers use the same inset-before-uncrop idea). Consider it the tool for people who've outgrown the one-click detailers and want to build the loop themselves.

Installing it

In mudknight-utils - ComfyUI Manager (search comfyui-mudknight-utils) or:

cd ComfyUI/custom_nodes
git clone https://github.com/mudknight/comfyui-mudknight-utils

It's pure tensor slicing - no dependencies beyond the pack's requirements.

Where people get burned

The trap is feeding it a bbox in the wrong coordinate space. If the bbox isn't relative to the same original image the crop came from, the inset math is wrong even though nothing errors - you'll just get misaligned composites. Keep the bbox output of your detector wired straight in rather than re-typing it, and remember the node doesn't re-detect anything; it assumes you've already found your region.

Categorymudknight/detailer

Inputs (3)

NameTypeDefaultDescription
crop_imageIMAGE
bboxBBOX
inset_pixelsINT80–512

Outputs (2)

NameTypeDescription
cropped_imageIMAGE
inset_bboxBBOX