π Image Crop
Turn a batch of masks into properly-sized crops for a detail pass
- image
- masks
- CROPPED_IMAGES
- CROPPED_MASKS
- CROP_DATA
If you've used Impact Pack's FaceDetailer, you already know the underlying trick: a face that's only 80x80 pixels inside a 1024x1024 image gets 80x80 pixels' worth of the model's attention when you sample the whole frame at once, and it comes out mangled. Crop just that region out, sample it at proper resolution on its own, then paste it back - and it comes out clean. Impact Pack bundles a YOLO/SAM detector to find those regions automatically; GOAT's Image Crop skips the detector entirely and works off whatever mask you hand it, from any source - manual painting, a segmentation node, someone else's detector output. This node's whole job is turning that mask into a properly-framed, properly-sized crop you can actually run a sampler on.
How it works
For each mask in the batch, it finds the bounding region, adds your requested padding around it so the crop has some surrounding context rather than cutting exactly at the mask edge, and then enforces a minimum crop size via context_size - because sampling a tiny 64x64 crop rarely gives a diffusion model enough to work with. If your detected region is smaller than context_size, the crop gets expanded (centered on the region) to meet it.
There's also an optional upscale stage built in specifically for tiny source regions: turn on upscale_images and the node will scale each crop up before handing it back, by upscale_factor, capped at max_upscale_size so a crop from a huge source image doesn't balloon unpredictably. That matters because a detail pass on something originally 40x40 pixels needs to be blown up before a sampler can add meaningful detail to it - this saves you a separate upscale node per crop.
Everything the node figures out - where each crop came from, what size it should be composited back at - gets bundled into CROP_DATA, which is the input GOAT's companion node Image Stitch needs to paste your edited crops back onto the original seamlessly. The two are meant to be used as a pair.
Inputs and outputs that matter
image- the source image.masks- a batch of masks, one crop per mask. Where these come from is entirely up to you.padding(0β512, default 32) - extra margin around each detected region.context_size(256β2048, default 256) - the minimum crop dimension; smaller regions get expanded up to this before anything else happens.upscale_images(default off) and, if enabled,upscale_factor(1β4, default 2) andmax_upscale_size(default 1024) - for boosting tiny crops before you sample on them.rescale_method(defaultlanczos) - the resize algorithm used for any intermediate resizing.
Three outputs: CROPPED_IMAGES, CROPPED_MASKS (both batches, same order), and CROP_DATA - the bookkeeping bundle that only Image Stitch knows what to do with.
How to install it
ComfyUI Manager: search "GOAT Nodes", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/AconexOfficial/ComfyUI_GOAT_Nodes.git
then restart. No model downloads for this one - it's pure image geometry.
Common issues & troubleshooting
Crops come out bigger than expected. That's context_size doing its job - it's a floor, not a target, so a small mask still produces at least a context_size-sized crop. If you genuinely want tight crops around small regions, lower context_size, keeping in mind that very small crops give a sampler less to work with in a subsequent detail pass.
Empty mask in the batch. A completely empty mask has no bounding region to crop, which is an edge case worth avoiding upstream (filter it out before this node) rather than assuming the node will silently skip it gracefully.
You need this paired with Image Stitch, not used alone. This node only crops - it doesn't put anything back. If your goal is a detail pass that ends up composited back onto the full image, you need Image Stitch downstream with the same CROP_DATA this node produced; skipping it just leaves you with a batch of disconnected crop images.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| masks | MASK | β | |
| padding | INT | 320β512 | β |
| context_size | INT | 256256β2048 | β |
| upscale_images | BOOLEAN | false | β |
| rescale_method | COMBO | lanczos | 5 options: nearest-exact, bilinear, area, bicubic, lanczos |
| upscale_factor | FLOAT | 2.001β4 | β |
| max_upscale_size | INT | 1024256β8192 | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| CROPPED_IMAGES | IMAGE | β |
| CROPPED_MASKS | MASK | β |
| CROP_DATA | CROP_DATA | β |