You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ai: image sizing can exceed maxRatio or produce NaN #59536
ImageSizing.fit() can return a size that violates the provider's maxRatio after snapping each edge to multiple. With the gpt-image limits, aspect: "1:3" at resolution: "1.5K" returns 880x2656 (3.018:1) instead of staying within 3:1.
Degenerate shapes also produce NaN: aspect: "0:0" or resolution: "0K" gives { width: NaN, height: NaN }, and ImageSizing.exact() reports success because comparisons with NaN are false. OpenAI and Meta then build sizes such as NaNxNaN.
Activity
opencode-agent commentedon Oct 27, 2026
Thanks for the detailed report. I reproduced both problems on the latest
dev(6aedf36) by calling the image-sizing code directly:ImageSizing.fit({ aspect: "1:3", resolution: "1.5K" })with the gpt-image limits (maxRatio: 3) returns 880x2656, which is 3.018:1 and over the limit.fitwith aspect1:0or0:1(and{ multiple: 16 }) returns{ width: NaN, height: NaN }, andImageSizing.exact(...)still succeeds for those aspects.The script below reproduces it. Run it from
packages/aiin a checkout. The open PR #59535 looks like it addresses this.Reproduction script (repro.ts)
Run it:
bun repro.ts