crop by bboxs
Crop an image batch to bounding boxes, all sized the same
- image
- bboxs
- cropped_images
If you've ever run a detector over a batch of images - faces, subjects, whatever - you end up with two things: the images, and a pile of bounding boxes telling you where the interesting part is. crop_by_bboxs is the node that turns that into something you can actually use: it crops every image in the batch down to its own bounding box, and hands you back a batch where every crop is the same size, which matters because batched tensors in ComfyUI have to line up dimensionally.
It's part of ComfyUI-WJNodes, a big personal grab-bag pack from a GitHub user going by 807502278 - image/mask cropping, video segment cutting, color and DensePose filtering, file utilities, a GPU benchmark, more. The README's own description is refreshingly honest: "a simple node package that I use myself." No big community following, just a toolkit someone built and shared.
How it works
For each image in the batch, the node takes the matching bounding box, expands it into a square region centered on the box's center, and crops that out. It then scales every one of those crops to the same final size, so a batch of ten differently-shaped detections comes out as one clean, uniform-size image batch. If an image in the batch has no detected box at all, you get back a flat gray frame instead of an error - a deliberate fallback rather than a pipeline-killing crash.
The inputs and outputs that matter
imageandbboxs- your image batch and the matching bounding-box data, one-to-one.bboxsis a custom pipe type, so it has to come from something upstream that actually produces it - this pack's own YOLO nodes, or another detector in your graph.square_method(default on) - how the box gets squared off before cropping: expand the box's shorter side out to match the longer one, or stretch the whole region into a square. Leave it on unless you specifically want stretched output.bbox_scale(default 1) - a multiplier on the box size before cropping. Bump it above 1 if your detector's boxes are a little tight and you're cutting off edges you want to keep.use_highest_confidence(default on) - if a frame has more than one candidate box, use the most confident one instead of skipping it.padding_value(default 1, meaning white-ish gray) - the fill color used both for frames with no box at all and for crop regions that spill past the image edge.
Output is a single cropped_images batch - uniformly sized and ready to feed into whatever per-crop step you're running next (a resample pass, a classifier, an upscaler).
How to install it
Easiest path is ComfyUI Manager: search "ComfyUI-WJNodes" and install. Manually, it's the usual:
cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git
Restart ComfyUI and it'll show up under WJNode/ImageEdit/ImageCrop. The README notes an optional pip install -r requirements.txt inside the pack folder, but says most dependencies are already covered by a normal ComfyUI install - you generally won't need it for this node specifically. No model downloads required here; the pack's optional model directory (torchvision, EasyOCR, SAM2 weights) belongs to other nodes in the pack, not this one.
Common issues & troubleshooting
Getting a gray box back instead of a crop. That's the no-detection fallback doing its job, not a bug - check that your bboxs input is actually populated for that frame, and that padding_value is set to something you'd recognize as "empty" rather than a color that blends into your image.
Crops look stretched instead of centered-square. That's square_method set to the stretch behavior rather than the expand behavior - flip it if you wanted the box padded out to a square instead of distorted into one.
bboxs input has nothing to plug into it. This node itself has no extra dependencies, but whatever's upstream of it might. If you're using this pack's own YOLO helper to generate boxes, that specific node needs Impact Pack installed alongside WJNodes - the crop node doesn't care, but its data source does.
Nothing about this node online. It's a small utility inside a personal pack rather than a headline feature, so don't expect to find much discussion if something looks off - test on a small batch first and read the behavior directly rather than hunting for a thread about it.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| bboxs | bboxs | — | |
| padding_value | FLOAT | 1.000–1 | — |
| square_method | BOOLEAN | true | — |
| use_highest_confidence | BOOLEAN | true | — |
| bbox_scale | FLOAT | 1.000.01–32 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| cropped_images | IMAGE | — |