String Ratio Gemini31FlashImage
The name says Gemini, but it never calls an API — no key needed
- image
- string
Let's get the elephant out of the room: String Ratio Gemini31FlashImage makes no API call. It has no key, no network request, nothing. What it does is dead simple - it looks at an image, figures out the closest Gemini 3.1 Flash image aspect ratio, and outputs that ratio as a string like 16:9. The Gemini bit is just which preset list it matches against. If you're later handing a ratio string to a Gemini image API node or a workflow template, this is the piece that keeps your input legal for the model's supported sizes.
How it works
It holds the list of aspect ratios Gemini 3.1 Flash image supports - the full spread from ultra-wide 8:1 down to tall 1:8, through the usual suspects (16:9, 4:3, 1:1, 9:16…). When an image is connected, it computes each frame's width/height and finds the nearest supported ratio, comparing in log-space so the matching is symmetric (a 1.4:1 image and a 1:1.4 image are treated with equal distance, instead of wide ratios always winning). One ratio per frame is emitted.
No image connected? Then the node does the other useful thing: it just passes through whatever you picked in selection. That makes it work as a manual ratio picker too - pick 16:9 from the dropdown, get 16:9 out. The whole node is a compatibility shim between "my image has an arbitrary aspect ratio" and "the model I want to call only accepts these few."
The inputs that matter
- selection (COMBO, default
1:1) - manual ratio choice, used when no image is connected. - image (
IMAGE, optional) - if connected, auto-matches the nearest ratio per frame.
One output: string (STRING) - the ratio label(s).
Installing it
ComfyUI Manager → search ComfyUI-1hewNodes → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI. No models, no API keys, no downloads - it's math on a lookup table. The pack still pulls heavyweight requirements on install (rembg, ultralytics, etc.), and it targets ComfyUI's newer comfy_api.latest API.
Common issues
Batch behavior is the thing to remember: with a multi-frame image connected, you get one ratio per line in the output (newline-joined). If you're feeding that string to something expecting a single ratio, a batch will hand it several. Also, "nearest" is still an approximation - an 17:9 image is closer to 16:9 than to 8:1, but it isn't exactly 16:9, so don't treat the output as a promise of zero distortion. And if no image is wired up, the node outputs your selection verbatim, so a stale dropdown value can silently dictate the ratio.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| selection | COMBO | 1:1 | 14 options: 8:1, 4:1, 21:9, 16:9, 3:2, 4:3, +8 |
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |