AI Image Size & Aspect Ratio Calculator
Enter an aspect ratio or pixel size, pick your AI model, and get the exact output dimensions that model actually accepts — snapped to its documented grid and megapixel limit. Stops "invalid size" errors and the warped, duplicated results that off-grid dimensions cause. No signup, nothing leaves your browser.
How it works
Every AI image model is trained at a specific resolution and on a specific pixel grid. Feed it a size that is off-grid or far from its trained area and you get the classic failure modes — an "invalid size" API error, a stretched composition, duplicated faces, or soft, smeared detail. This tool returns a size that is both valid and well-conditioned for the model you choose. There are two code paths.
Fixed-size models — DALL·E 3, GPT-Image-1, and Midjourney v6 — accept only an enumerated set of dimensions. We pick the supported size whose aspect ratio is closest to your request, measured by the scale-invariant distance |ln(requestedAR) − ln(sizeAR)|. Using log-distance means 2:1 is treated as exactly as far from 1:1 as 1:2 is — the natural way to compare ratios. The answer is always a size the provider documents.
Grid models — SDXL, SD 1.5, SD 3.5, and FLUX.1 — accept any size that lands on their grid and near their trained area. Given a target area A (megapixels × 1,000,000), a requested ratio r = W/H, and a grid multiple G:
height = round( sqrt(A / r) / G ) × G width = round( (r × sqrt(A / r)) / G ) × G then clamp each side to the model's [minSide, maxSide] and re-snap.
The grid multiple is 64 for SDXL, SD 1.5, and SD 3.5 — these models downsample by 8 into latent space and pool by a further 8, so each side must divide by 64. FLUX.1 uses a 16-pixel grid. If clamping a side to the model's limits changes the value, the result is flagged clamped rather than pretending the exact ratio was honoured.
SDXL gets one extra step. After snapping, we check the result against the aspect-ratio bucket table from the SDXL technical report — the sizes the model was explicitly trained on. If it matches a bucket (for example 1344×768 for 16:9), we return it verbatim and label it a native SDXL bucket, the sharpest possible choice for that ratio.
All arithmetic is integer after the initial square root, so the output is exactly reproducible — there is no floating-point drift in the dimensions shown. The three worked examples below are encoded as a live self-test:
- SDXL · 16:9 · 1.0 MP → expected 1344×768, got 1344×768
- DALL·E 3 · 16:9 → expected 1792×1024, got 1792×1024
- FLUX.1 · 3:2 · 2.0 MP → expected 1728×1152, got 1728×1152
- SD 1.5 · 1:1 · 0.262 MP → expected 512×512, got 512×512
- SDXL · 4:1 (clamped) · 1.0 MP → expected 1536×640, got 1536×640
Need the other half of the workflow? Estimate what a batch of these images will cost on the AI Image Generation Cost Calculator, or resize a photo you already have with the Image Resizer.
Worked examples
Frequently asked questions
Sources & references
- OpenAI — Images API reference (DALL·E 3 and GPT-Image-1 supported sizes)
- Stability AI — SDXL 1.0 model card (1 MP base, ×64 grid, bucket table)
- Stability AI — SDXL technical report / announcement
- Stability AI / RunwayML — Stable Diffusion v1.5 model card (512 base)
- Stability AI — Stable Diffusion 3.5 (≈1 MP target, ×64 grid)
- Black Forest Labs — FLUX.1 model card (0.1–2.0 MP, ×16 grid)
- Midjourney — Aspect Ratios documentation (--ar rules, v6 base dimensions)
Size enums, bucket tables, grid multiples, and megapixel limits were last cross-checked against each model's official documentation on 2026-06-06. The data is reviewed whenever a vendor ships a new model version. Spotted a stale value? Email the address below — most fixes ship within 24 hours.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a size rule that has changed, or a model the calculator should add?
Email me at [email protected] — most fixes ship within 24 hours.