Nodes/WAS Node Suite v3/Bounds to Crop Data
ComfyUI Node Runs on cloud

Bounds to Crop Data

Close the crop-and-paste loop

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Bounds to Crop Data
  • image_bounds
  • crop_data
index0

Cut a region out, work on it at high resolution, put it back exactly where it came from. That crop-and-paste round trip is the backbone of face detailing and region fixes, and it only works if the node doing the pasting remembers where the piece came from and how big it was. Bounds to Crop Data is the little converter that carries that memory between WAS's two rectangle formats.

There are two rectangle values in play and they describe different jobs. Bounds (IMAGE_BOUNDS) is a set of regions - it can hold one row per image in a batch, which is what you want when you measured something. Crop data (CROP_DATA) is a single rectangle with a size attached, which is what the paste nodes read. One bounds value, several rows → one crop window, one rectangle. The bridge between them needs an index, and that's exactly the shape of this node.

Under WAS Suite/Image/Bound, it takes image_bounds (from Image Bounds, Inset Image Bounds, Mask to Bounds, or Image Crop by Mask) and an index saying which row travels on. Index 0 is the first row; -1 counts back from the end. Ask for a row that isn't there and it raises an error that names how many rows the bounds holds - the loud failure is intentional, since a silent wrong-row would paste a face back over somebody else's eyes.

The output is one crop_data value. The subtlety is in how the crop window is recorded: "at the size the rectangle covers." So when you crop a region, upscale it 4x, fix it, and paste it back, the paste node knows the original rectangle's dimensions and resizes your high-res patch down to sit exactly where it was measured. That's what keeps a detailed face landing back at face-size instead of splattered across the image.

Where it sits in the loop

The pairing it exists for: measure with the bounds nodes (say, a mask turned into bounds, or a region you inset for breathing room), then hand the region to Bounded Image Crop to cut it out. Work on the crop - upscale, regenerate, inpaint. When it's time to put it back, the paste side of the loop (Image Paste Crop or Mask Paste Region) reads crop data, and this node is what produces that data from your bounds. Keep the same bounds value that fed the crop and the index that named your region, and the paste is exact by construction. Forget the index and you get the classic "the wrong region came back" bug - which is why the node raises rather than guessing when the row is missing.

Installing

Part of WAS Node Suite v3 (WASasquatch/was-node-suite-comfyui), WASasquatch's MIT pack - going since 2023, over a million downloads, the historical home of most of these crop/composite operations in ComfyUI. Pure conversion logic, zero dependencies: no packages, no models, nothing downloaded. Requires ComfyUI 0.14.0+ (the v3 suite runs on ComfyUI's newer node backend).

Via ComfyUI Manager, search WAS Node Suite v3, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui

Restart ComfyUI and it appears under WAS Suite/Image/Bound. Missing from the menu after a clean install? Update ComfyUI first - that's the standard fix for this pack.

CategoryWAS Suite/Image/Bound

Inputs (2)

NameTypeDefaultDescription
image_boundsIMAGE_BOUNDSThe rectangle to convert, from Image Bounds, Inset Image Bounds, Mask to Bounds or Image Crop by Mask.
indexINT0-16384–16384Which row to convert. 0 = the first row; -1 = the last, counting back from the end. A row that is not there raises, naming how many rows the bounds hold.

Outputs (1)

NameTypeDescription
crop_dataCROP_DATAThe same rectangle as a crop window, recorded at the size the rectangle covers. A paste node resizes whatever it is handed to that size, so a region worked on at a higher resolution lands back at the size it was measured at.