Gpt Image Size Calculator
GPT Image won't take your resolution — this node finds one it will
- image
- image
- width
- height
- size
- aspect_ratio
- info
The problem it actually solves
GPT Image doesn't take arbitrary sizes. A custom canvas has to be a multiple of 16 on both edges, no edge bigger than 3840, a width/height ratio between 1:3 and 3:1, and an area between 655,360 and 8,294,400 pixels - anything past 2560×1440 is the maintainer's own "experimental" band. Feed it a 3678×4598 camera frame and you get either a refusal or a quietly different shape back, which is exactly the kind of thing that ruins a round trip through a closed image-editing model. Since GPT Image has no open weights, the API node is the only door into it (external-api-nodes.md), and this pack is the person standing at that door with a ruler.
First thing to get out of the way: the name is a lie. There's no key, no network call, no model download. It's arithmetic plus a resize, running entirely on your machine - verified in the source, where pyproject.toml declares dependencies = [] and the sizing logic is one file of pure Python.
How it works
There are four sizing policies, and they are not four flavors of the same thing.
NanoSeed 4K (verified), the default, is a reimplementation of the local size calculation in the NanoSeed node pack - the community wrapper that reaches Fal for Seedream/GPT-image style edits. It preserves your orientation, clamps the long/short ratio at 3, computes an ideal long edge of min(3840, sqrt(8,294,400 × ratio)), and then tries only the floor and ceiling multiples of 16 on each edge. That's four candidate canvases, not a search. It keeps the ones that pass every rule and picks the largest area, with ratio error as the tie-breaker. It ignores pixel_budget and max_crop_percent entirely.
The other three: Max area (experimental estimate) walks the whole 16px grid under your budget and takes the biggest canvas within max_crop_percent of your ratio; Closest aspect picks the nearest ratio among canvases that use at least 95% of the ideal feasible area; Exact dimensions just validates target_width/target_height and uses them, ignoring the budget and the crop tolerance.
Then fit decides what happens to the pixels. Crop (default) takes the largest rectangle at the target ratio, anchored by crop_x/crop_y (0.5 is centered), trims, and bicubic-resizes to the canvas. Pad rescales the whole frame to fit inside and letterboxes with actual zero-black. Either way it's bicubic with antialiasing and a clamp to 0–1 - a plain interpolator, so it can't invent detail, and a big upscale will visibly soften (upscaling.md).
Inputs and outputs that matter
image is the only required input. Of the rest you'll touch sizing_mode, fit, and crop_x/crop_y; target_width/target_height (defaults 2592×3200) only do anything in Exact dimensions mode; pixel_budget is a node policy knob, not a quality setting.
Outputs: image (the prepared canvas), width and height (feed these to your generation node), size (the "2576x3216" string OpenAI's size parameter wants), aspect_ratio (gcd-reduced - 2576×3216 becomes 161:201), and info, one long string with the crop rect or pad offsets, the estimated crop loss, and which policy ran.
If width/height need to land on widgets, right-click the receiving node and Convert widget to input. And note the README's flat warning: none of this forces a downstream node set to auto to keep your canvas.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/comrender/ComfyUI-Gpt-Image-Size-Calculator.git
Restart ComfyUI and search "Gpt Image Size Calculator". Or search the pack title in ComfyUI Manager (registry id gpt-image-size-calculator, publisher comrender). Needs Python 3.10+, and yes, that's the whole install - there is nothing to pip install, since ComfyUI already supplies PyTorch.
Where people get burned
Your output resolution will not match your input resolution, and that's the point. In the maintainer's test set, 3600×4500 and 1800×2250 both landed on 2576×3216 - the ratio drives the result, not the pixel count. A 1024×1024 square comes out 2880×2880 and gets bicubic-upscaled on the way, so if you were counting on native detail, prepare at the size the model already likes.
Sizes that are already legal pass through untouched: 2592×3200 stays 2592×3200.
The "verified" label deserves a caveat. It's 12 user-supplied Sunburst outputs matched against a local reimplementation of NanoSeed's rounding rule, with the source hash recorded at analysis time. That is a real check on a real workflow, and it is not a prediction of what OpenAI's server does with auto - the README says so outright. Max area mode matched only 4 of those 12, which is why it's labeled experimental.
Crop mode trims without asking. Read info and check the crop-loss percentage; crop_x/crop_y are your rescue when the subject isn't centered.
Last thing: this is a brand-new, single-maintainer pack with essentially no community footprint yet. It's two readable Python files, which is genuinely the best you can do when evaluating a node pack nobody has vetted (troubleshooting.md).
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| sizing_mode | COMBO | NanoSeed 4K (verified) | NanoSeed 4K (verified) matches the local NanoSeed auto-size algorithm; its fixed 4K budget ignores pixel_budget and max_crop_percent. |
| pixel_budget | INT | 8294400655360–8294400 | — |
| max_crop_percent | FLOAT | 2.00–25 | — |
| target_width | INT | 259216–3840 | — |
| target_height | INT | 320016–3840 | — |
| fit | COMBO | Crop | 2 options: Crop, Pad |
| crop_x | FLOAT | 0.500–1 | — |
| crop_y | FLOAT | 0.500–1 | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| size | STRING | — |
| aspect_ratio | STRING | — |
| info | STRING | — |