NB2 Mask Generator
NB2 Mask Generator — the manual rectangle for people who know exactly where to edit
- image
- mask
- nb2_width
- nb2_height
- preview_image
Nano Banana 2 doesn't inpaint, and this node is the most literal version of the pack's workaround: you draw a rectangle, the pack crops to it, Nano Banana regenerates it, and the stitch pastes it back. No segmentation model, no API call, no guesswork - just a positioned box on your image.
NB2 Mask Generator is the "manual" entry point into the NB2 crop/stitch path, for when you know the exact region you want regenerated and don't need a Florence-2 or SAM model to find it for you. It's the node the pack's demo workflow (00_manual_nb2_crop_stitch_nano_banana2.json) starts from, and it's the easiest way to verify the whole roundtrip works before you add smart selectors.
The inputs that matter
Required inputs are image, the geometry, and the shape:
center_x/center_y- the center of your crop rectangle, in pixels on the original image. These are what you'll actually drag around as you dial in the region. Defaults of 512/512 are rarely where you want to be.crop_width- width of the rectangle on the source. Height is auto-calculated from the aspect ratio, so you only set one dimension. Clamped if it would exceed the image.aspect_ratio(16:9,9:16,1:1) andresolution(1K,2K,4K) - the shape and budget. These must match what you set onNB2 Croplater, because together they pick the exact Nano Banana output size (16:9 @ 2K → 2752×1536, etc.).
Outputs: mask (the rectangle mask, into NB2 Crop), nb2_width / nb2_height (the exact NB2 output dimensions, if you want them as ints), and preview_image - a copy of your source with the crop rectangle drawn on it. Wire that into any Preview Image node and you get instant visual feedback on where the rectangle sits before you waste a generation on it. That preview is genuinely the most useful output here; without it you're flying blind.
The flow
NanoBanana2MaskGen -> mask -> NB2 Crop -> Nano Banana 2 Edit -> NB2 Stitch
If you'd rather not hand-place the box, skip this node and feed a semantic mask from NB2Florence2RegionSelector or NB2SAM3ImageSegmenter into NB2 Smart Region, which auto-fits the rectangle. But for a first test, or for edits where the smart models keep grabbing the wrong thing, manual is faster and more predictable.
Install
Search comfyui-inpaint-cropstitch-nb2 in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/amortegui84/comfyui-inpaint-cropstitch-nb2
Restart. Nothing to download - this node is pure local geometry, no FAL key needed for it (the edit node downstream is the part that needs the key).
Gotchas
The classic mistake is setting the rectangle to cover more than you intend. Nano Banana will regenerate the whole crop, not just the mask, so a loose rectangle means the model rewrites background it shouldn't have touched - that's the drift that crop-and-stitch exists to prevent. Keep the box tight around what you want changed, then use the preview_image output to confirm. And remember the matching rule: whatever aspect_ratio and resolution you pick here, NB2 Crop must be set identically, or the stitch resamples and the seam shows.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| aspect_ratio | COMBO | 16:9 | 3 options: 16:9, 9:16, 1:1 |
| resolution | COMBO | 2K | 3 options: 1K, 2K, 4K |
| center_x | INT | 5120–16384 | Horizontal centre of the crop rectangle in pixels. |
| center_y | INT | 5120–16384 | Vertical centre of the crop rectangle in pixels. |
| crop_width | INT | 96064–16384 | Width of the crop region on the original image in pixels. Height is auto-calculated from the aspect ratio. Clamped if larger than the image. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| nb2_width | INT | — |
| nb2_height | INT | — |
| preview_image | IMAGE | — |