induwara.lk
induwara.lkAI · Image sizing

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.

By Induwara AshinsanaUpdated Jun 6, 2026
AI image dimensionsStability AI
Docs-verified sizes

1 MP target, dimensions in multiples of 64, snapped to the official bucket table.

Type two whole numbers like 16:9, or tap a preset.

Presets
Target MP
Recommended dimensionsNative SDXL bucket
1024×1024px
Aspect ratio
1:1
1.000:1
Megapixels
1.05 MP
1,048,576 px
Ratio drift
Exact
Matches your request

Snapped to 1024×1024, which is a published SDXL aspect-ratio bucket — the ideal, artefact-free size for this ratio.

Stable Diffusion XL supported sizes

RatioDimensionsMegapixels
1:11024 × 10241.05 MP
16:91344 × 7681.03 MP
9:16768 × 13441.03 MP
4:31152 × 8961.03 MP
3:4896 × 11521.03 MP
3:21216 × 8321.01 MP
2:3832 × 12161.01 MP
21:91536 × 6400.98 MP

Sizes cited from each model's official documentation — OpenAI Images API, the SDXL technical report, Stability AI SD 1.5/3.5 cards, the FLUX.1 model card, and Midjourney's aspect-ratio docs. Full source list is below the calculator.

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

Stable Diffusion XL · 16:9 thumbnail · 1.0 MP

A freelancer making a YouTube thumbnail in SDXL. Typing 1365×768 warps the image; here is the right size.

  1. Target area A = 1.0 MP × 1,000,000 = 1,000,000 px²; r = 16/9 = 1.778; grid G = 64
  2. height = round( sqrt(1,000,000 / 1.778) / 64 ) × 64 = round(750/64)×64 = 12×64 = 768
  3. width = round( (1.778 × 750) / 64 ) × 64 = round(1333/64)×64 = 21×64 = 1344
  4. 1344×768 is a published SDXL bucket → returned verbatim
  5. Result: 1344 × 768 px · 1.03 MP · 7:4 · 'Native SDXL bucket'

DALL·E 3 · landscape 16:9 request · fixed-size model

DALL·E 3 has no 16:9 — only three sizes. The tool returns the closest valid one.

  1. Allowed sizes: 1024×1024 (1.00), 1792×1024 (1.75), 1024×1792 (0.571)
  2. Requested ratio = 16/9 = 1.778 → ln(1.778) = 0.575
  3. ln-distances: 1024×1024 → 0.575, 1792×1024 → 0.016, 1024×1792 → 1.135
  4. Closest is 1792×1024
  5. Result: 1792 × 1024 px · 1.84 MP · 7:4 · 'Native supported size' (no exact 16:9)

FLUX.1 · 3:2 · 2.0 MP ceiling · grid G = 16

Pushing Flux to its documented 2.0 MP maximum at a 3:2 ratio.

  1. A = 2.0 MP × 1,000,000 = 2,000,000 px²; r = 3/2 = 1.5; grid G = 16
  2. height = round( sqrt(2,000,000 / 1.5) / 16 ) × 16 = round(1154.7/16)×16 = 72×16 = 1152
  3. width = round( (1.5 × 1154.7) / 16 ) × 16 = round(1732/16)×16 = 108×16 = 1728
  4. Aspect check: 1728/1152 = 1.5 exactly = 3:2
  5. Result: 1728 × 1152 px · 1.99 MP · 3:2 · 'Snapped to ×16 grid'

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

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.