✂️ BoxCrop
Crop exactly the box you drew, with the coordinates intact
- image
- cropped_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_metadataoutput. Wire them together and it just works. - fallback_mode - what happens when there are no usable coordinates. Default
use_full_imagereturns the whole image untouched.return_zerogives you a black tensor.errorraises 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_modeisuse_full_image, so an empty or unconnectedbox_metadatadoesn't error - it quietly passes the image through. If your "crop" isn't cropping, check that BoxSelector'sbox_metadataoutput is actually wired into this node'sbox_metadatainput, 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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| box_metadata | STRING | — | |
| fallback_modeopt | COMBO | use_full_image | 3 options: use_full_image, return_zero, error |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |