NanoBanana - Image Edit
Tell Google what to change, not how to change it
- image
- mask
- reference_image
- reference_image_2
- reference_image_3
- network
- image
Local diffusion editing is a bag of tricks: inpaint with a mask, redraw with controlnet, paste a face in and hope the lighting matches. This node takes the other route entirely - you hand an image to Gemini, type "make it golden hour, swap the car to red, and remove the lamp post," and the model regenerates the image to match. No mask required, though you can supply one if you want to constrain where the magic happens.
It's the natural pairing for the pack's ImageGen node: generate something, then iterate on it conversationally. Where it shines is instructed edits - "change this," "make that," "remove this thing" - the kind of edit that's genuinely hard to express as a mask and a prompt. The trade, same as always with the closed models: you're inside Google's content policy and you pay per edit.
How it works
The node assembles a multimodal request: your source image encoded as lossless PNG (so fine details survive), an optional mask as a second PNG, up to three optional reference images (for face swaps or style references), and your edit_instruction as text. All of it goes to a Gemini image model via generate_content, and the edited image comes back as a standard IMAGE tensor.
Key inputs:
- image - what you're editing.
- edit_instruction - natural language describing the change. This is the whole point; be specific.
- mask - optional. White = edit this area, black = keep. It accepts any ComfyUI MASK - SAM, Grounding DINO, alpha channels, background removal, whatever. The pack silently resizes your mask to match the image dimensions, because Gemini 400s on a size mismatch.
- reference_image / reference_image_2 / reference_image_3 - optional sources, e.g. a face to swap into a region.
- aspect_ratio and image_size - output geometry (AUTO by default).
Output: image, a plain IMAGE tensor.
Installation
It's part of the NanoBanana2 pack, so one install gets you this plus the other 28 nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai
ComfyUI Manager: search NanoBanana2. Needs an API key from aistudio.google.com, settable per-node or via GEMINI_API_KEY.
Gotchas
Set your expectations about the mask. Gemini doesn't do pixel-perfect masking - it treats your mask as strong visual guidance, not a hard boundary, and the pack's own tooltip admits this. If you need surgical precision on a tiny region, a local inpaint model with a proper mask will beat it; use this node when "edit this general area, understand what I mean" is the requirement. Also: the output dimensions follow the aspect/size you set, which can differ from the input - if you need the result to be exactly the same resolution as the source, say so in the instruction and keep aspect_ratio at AUTO.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | NanoBanana - API key. Leave blank to use GEMINI_API_KEY env var. | |
| model | COMBO | gemini-3.1-flash-image-preview | Image-capable Gemini model for editing. |
| custom_model | STRING | Override with a custom model ID. | |
| image | IMAGE | The image to edit. | |
| edit_instruction | STRING | Describe what edits to make to the image. | |
| maskopt | MASK | Optional mask — which areas to edit. White = edit, black = keep. Works with any MASK source: SAM, Grounding DINO, segmentation, alpha channels, RMBG. Gemini doesn't do pixel-perfect masking — it uses this as visual guidance alongside your instructions. | |
| reference_imageopt | IMAGE | Optional reference image (e.g., a face to swap into the masked region). | |
| reference_image_2opt | IMAGE | Optional second reference image. | |
| reference_image_3opt | IMAGE | Optional third reference image. | |
| system_instructionopt | STRING | System instruction for the editing model. | |
| aspect_ratioopt | COMBO | AUTO | Output image aspect ratio. |
| image_sizeopt | COMBO | AUTO | Output image resolution. |
| networkopt | NB_NETWORK | Optional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |