Nodes/BoxBox/✂️ BoxCrop
ComfyUI Node

✂️ BoxCrop

Crop exactly the box you drew, with the coordinates intact

By mercu-lore·Created 10 months ago·Updated 7 months ago· 3
✂️ BoxCrop
  • image
  • cropped_image
box_metadata
fallback_modeuse_full_image

BoxCrop is the scissors of the BoxBox pack. You draw a rectangle with BoxSelector, and this node cuts exactly that region out of the image - no manual ImageCrop math, no guessing pixel offsets. Feed it an image and the box_metadata string from BoxSelector, and out comes cropped_image: a tensor of just what you boxed.

The whole point of this kind of crop is the "render the region at real resolution" trick. A small region inside a big frame gets a tiny slice of the model's attention, which is why faces and hands come out mangled; crop it, run it through generation at a proper resolution, and paste it back and a 64px eye gets a full 1024px of generation budget. That's the same detect-crop-refine idea Impact Pack's FaceDetailer made famous - BoxBox just lets you draw the region by hand instead of letting a detector find it.

How it works

Under the hood, BoxCrop parses the box_metadata JSON, pulls out x1, y1, x2, y2, and slices the image tensor. The genuinely useful bit: it reads the displayScaleFactor that BoxSelector stamps into the metadata and divides the coordinates by it. That's what makes the crop land where you actually clicked even when the preview was downscaled for drawing - this is the "no double-scaling" fix this pack's enhanced version is known for. Coordinates get normalized (it doesn't care if you dragged the box backwards), clipped to the image edges, and rounded to whole pixels.

The inputs that matter

  • image - the image you're cropping.
  • box_metadata - the JSON string from BoxSelector's box_metadata output. Wire them together and it just works.
  • fallback_mode - what happens when there are no usable coordinates. Default use_full_image returns the whole image untouched. return_zero gives you a black tensor. error raises instead.

Only one output: cropped_image. It's batch-safe (it crops every frame of a batch the same way), so you can run it on video frames without drama. Wire the crop into a VAEEncode → sampler → VAEDecode loop for the detail pass, or feed it straight into BoxResize.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/mercu-lore/BoxBox

Restart ComfyUI (or use Manager → search "BoxBox"). Requirements are just torch, numpy, and Pillow - nothing extra to download, no models. It's one of the few packs where the install is genuinely boring, in a good way.

Common issues

  • You get the whole image back instead of a crop. That's the silent trap: default fallback_mode is use_full_image, so an empty or unconnected box_metadata doesn't error - it quietly passes the image through. If your "crop" isn't cropping, check that BoxSelector's box_metadata output is actually wired into this node's box_metadata input, and that the node ran after you drew a selection.
  • Crop lands off-target on large images. The coordinate scaling path handles this in current versions, but if you're on an old clone, update the pack - the misaligned-crop bugs lived in the coordinate scaling, not the slicing.
  • Crop looks wrong after a processing node. If a Brightness or Blur node sits between the source and BoxSelector, the preview shows the unprocessed image but coordinates still apply to the processed one - correct output, confusing preview. Known limitation, not a bug in the crop.
Categoryimage/region

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
box_metadataSTRING
fallback_modeoptCOMBOuse_full_image3 options: use_full_image, return_zero, error

Outputs (1)

NameTypeDescription
cropped_imageIMAGE