String Ratio Gpt20Image
Snap any image to the nearest GPT Image 2.0 ratio, locally
- image
- string
GPT Image 2.0 is picky about aspect ratios - it accepts a specific set and will bend your image to whatever you declare. This node exists to make sure you declare the right one. Feed it an image and it outputs the nearest ratio from the GPT 2.0 image set, as a plain string. And to be clear about the "GPT" in the name: there's no OpenAI call here. No API key, no network. It's a local lookup against the ratio list GPT 2.0 image actually supports.
How it works
The node carries the GPT 2.0 image ratio set - from wide 3:1 down to tall 1:3, including the standard studio crops (16:9, 3:2, 4:3, 5:4, 1:1, and their portrait mirrors). When an image is connected, each frame's width/height is matched to the nearest supported ratio using log-space distance, which keeps the matching fair in both directions - a 1.8:1 image lands on 2:1 or 16:9, not automatically on the most extreme wide option. Output is one ratio per frame.
No image connected? It passes through your selection value unchanged. So the node has two lives: an auto-matcher for images, and a plain ratio picker when you're declaring a ratio by hand for a prompt string. That dual behavior is exactly what you want when building a workflow that can either take an input image or be driven by a manual choice.
The inputs that matter
- selection (COMBO, default
3:2) - the manual fallback ratio. - image (
IMAGE, optional) - auto-match mode.
One output: string (STRING) - 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, nothing to download - it's a comparison against a constant list. Pack-level notes: requirements are heavy regardless (rembg, ultralytics, transformers), and the pack uses ComfyUI's newer comfy_api.latest API, so update ComfyUI if nodes don't show.
Common issues
Same family of gotchas as its Gemini sibling. With a batch connected you get one ratio per line - a multi-line string, not a single value. "Nearest" means nearest, so expect slight divergence from the exact pixel ratio of your source; if you need pixel-perfect, this isn't the tool. And watch the selection-pass-through: with no image connected the dropdown decides everything, so a default 3:2 sitting in the field is the whole story. If your downstream GPT Image node rejects the ratio string, double-check it's actually in the 2.0 supported set - the list here tracks the current presets, but API-side lists have been known to shift.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| selection | COMBO | 3:2 | 15 options: 3:1, 21:9, 2:1, 16:9, 3:2, 4:3, +9 |
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |