Nano Banana Size Calculator
Nano Banana resizing without the guesswork — a calculator that knows the buckets
- image
- width
- height
- info
- aspect_ratio
Nano Banana (Google's Gemini image model, served through the API) has one quirk that trips everyone up in ComfyUI: it wants its inputs snapped to a fixed set of aspect-ratio buckets, roughly a megapixel, with dimensions divisible by 32. Feed it a random 1504×893 canvas and the output comes back shifted, cropped, or - as anyone who's run it through a pipeline will tell you - "a different aspect ratio, slightly zoomed." That frame drift is exactly the thing this node exists to kill. Give it any image, it hands you back the exact width and height the model is actually expecting.
What it actually does
This is a pure calculation node - pure Python, zero GPU, zero model files, nothing to download. It looks at your image tensor, figures out the aspect ratio and orientation, then picks the nearest dimension pair from the bucket list that matches your model preset. That's the whole job, and the whole pack is this one node, so there's no bloat to trip over.
Under the hood it's simple distance math. The node compares your input's width/height against every bucket in the current preset, finds the closest by squared pixel distance, and returns it. The author's baked in a few manual overrides for known problem inputs (a 1731×2423 image, for instance, gets forced to 1792×2400 instead of whatever pure distance math would pick). And when your image is a true outlier - far from every bucket - the default "Clamp" method falls back to choosing a bucket by aspect ratio and preferring the largest plausible one, rather than snapping to some extreme 1024×4096 sliver that technically matches your height.
The inputs that matter
The good news: you mostly set two things and forget it.
- image - any image tensor. It only reads the dimensions, so size and content don't matter.
- preset -
NB 1,NB 2 (1K),NB 2 (2K),NB 2 (4K), defaultNB 2 (2K). This picks the bucket table. If you're on the original Nano Banana, useNB 1(its 22 buckets span 512×2048 up to 2048×512). The 2K and 4K presets cover the Pro model's bigger resolutions. Mismatch the preset and your "exact size" becomes approximate - pick the one that matches the model you're calling. - method -
Clamp (reccomended)is the default for a reason;Dynamic (legacy)keeps the old ceil-to-32 behavior and can produce dimensions that aren't in the fixed bucket list at all;Staticjust forces the raw closest bucket.
Yes, "reccomended" is misspelled in the dropdown. It's still the right choice.
The outputs
- width, height - the two INTs you actually use. Wire them into an
ImageScale/ImageScaleToTotalPixels-style resize node in front of your Nano Banana API node so the image lands exactly on the bucket. - info, aspect_ratio - diagnostics.
infois a readout likeNB 2 (2K) • 1792×2304 • AR: 4:3 • Input: 1732×2213, andaspect_ratiois the Gemini-compatible ratio string the API accepts.
Installing it
Straightforward, and it's a rare pack with no dependencies to babysit:
cd ComfyUI/custom_nodes
git clone https://github.com/comrender/ComfyUI-Nano-Banana-Resizer
Restart ComfyUI, and "Nano Banana Size Calculator" shows up under image/transform. Or skip all that - ComfyUI Manager can find it by searching "ComfyUI-Nano-Banana-Resizer" and install it in two clicks. No requirements install step, no models, no API keys. It's one of the few nodes that genuinely "just works."
Where people get burned
The number one gotcha is expecting the node to resize your image. It doesn't - it only computes numbers. You still have to feed width and height into a resize node yourself, then connect that to Nano Banana. Forgetting that step is how people end up with a calculator that "does nothing."
Second: preset confusion. The default is NB 2 (2K), but plenty of workflows are still running original Nano Banana (the NB 1 bucket set) or calling Pro at 4K. If your outputs look subtly wrong, check the preset before you blame the resize node.
Third, the fallback note. When the picked dimensions aren't in the fixed bucket list, info appends "(Not in fixed bucket list)" - that's the node telling you the input was an outlier and you're on the ceiling-to-32 path. Usually fine, but worth a glance.
It's a small tool, but it removes a whole class of "why is my Banana output zoomed and shifted" debugging. For a few minutes of setup, that's a good trade.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| preset | COMBO | NB 2 (2K) | 4 options: NB 1, NB 2 (1K), NB 2 (2K), NB 2 (4K) |
| method | COMBO | Clamp (reccomended) | 3 options: Clamp (reccomended), Dynamic (legacy), Static |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| info | STRING | — |
| aspect_ratio | STRING | — |