AI Image Aspect Ratio Calculator

16:9 with 1024 px on the longest side and multiples of 64 is 1024 × 576. For SDXL the closest trained size is 1344 × 768.

Resolution to ratio

Service limits are taken from each provider's documentation and can change.

Did this solve your problem?
Prefer us on Google

How to use

  1. Pick a ratio from the list or type your own width and height ratio, for example 16 and 9.
  2. Choose whether the size is set by the longest side in pixels or by total megapixels, then enter the value.
  3. Pick the multiple. Use 64 for Stable Diffusion style models, 16 for OpenAI, and 8 for the most flexible sizes.
  4. Read the resolution, the small ratio error caused by rounding, and the closest size each service accepts. To check an existing image, type its width and height in the second block.

How it works

For a ratio W:H and a longest side L, the long edge is L rounded to the multiple and the short edge is L × (short ÷ long) rounded to the multiple. 16:9 with L = 1024 and multiples of 64 gives 1024 × 576, because 576 is exactly 9 × 64.

For megapixels, the width is the square root of (pixels × W ÷ H) and the height follows from the ratio. Both are rounded to the multiple, and the better of the width first and height first candidates is kept.

Rounding changes the ratio a little. 3:2 at 1024 and a multiple of 64 gives 1024 × 704 (about 1.4545), a 3 percent error, shown in the deviation row. A multiple of 8 gives 1024 × 680 and a smaller error.

A resolution is turned into a ratio by dividing both sides by their greatest common divisor, so 1920 × 1080 is 16:9 and 1366 × 768 is 683:384, which the tool also matches to the nearest common ratio, 16:9.

Why multiples of 64 and 8

Latent diffusion models such as Stable Diffusion work on a compressed grid that is 8 times smaller than the image, and the network downsamples that grid several more times. Sizes that are multiples of 64 divide evenly through every stage, so most local tools ask for them. The SDXL paper trained on sizes that are all multiples of 64.

Hosted services set their own rules. OpenAI's GPT Image models accept custom sizes if both sides are multiples of 16. Midjourney takes a ratio and decides the pixels itself.

Supported sizes by service

ServiceSizes and limitsSource
OpenAI GPT ImageRecommended 1024×1024, 1536×1024, 1024×1536. Custom: both sides multiples of 16, ratio from 1:3 to 3:1, longest side up to 3840, 655,360 to 8,294,400 pixels in total. Above 2560×1440 is experimental.platform.openai.com/docs/guides/image-generation
Midjourney--ar width:height with whole numbers, no decimals. The default is 1:1. Midjourney chooses the pixel size.docs.midjourney.com, Aspect Ratio
Stable Diffusion XL40 sizes of about 1 megapixel, all multiples of 64, from 512×2048 to 2048×512. Includes 1024×1024, 1152×896, 1344×768 and 768×1344.SDXL paper, arXiv 2307.01952, appendix I

Tips

  • Pick the ratio for where the image will be used first: 1:1 for square posts, 4:5 or 3:4 for portrait feeds, 9:16 for stories and shorts, 16:9 for video and covers.
  • Generate near the model's native size and upscale afterwards. Asking an SDXL model for a size far from its 1 megapixel buckets often gives repeated subjects.
  • If a service rejects a size, the cause is usually a multiple or pixel limit, so check the rows for it above.

FAQ

What size should I use for 16:9 in Stable Diffusion XL?

Use 1344 × 768, which is in the list of sizes SDXL was trained on. For vertical 9:16 use 768 × 1344. Both are multiples of 64.

Can I use any size with GPT Image?

Not any. The three recommended sizes are 1024×1024, 1536×1024 and 1024×1536. Custom sizes work if both sides are multiples of 16, the ratio is between 1:3 and 3:1, the longest side is at most 3840, and the total pixels are between 655,360 and 8,294,400. Sizes above 2560×1440 are marked experimental.

Does Midjourney use pixel sizes?

You give it a ratio with --ar, such as --ar 16:9, and it picks the output size. The ratio uses whole numbers, so write 139:100 instead of 1.39:1. This tool shows the simplified ratio for your input.

Why is the ratio slightly off?

Both sides must be multiples of the number you chose, so one side is rounded. A larger multiple means a larger error. If the error matters, use a smaller multiple or a larger image.

Is anything uploaded?

No. Everything is calculated in your browser.