New Tool Radar

AI Concepts

How to Check an Image’s Size Against Vision Model Input Limits

Check an image's size against vision model input limits before sending it, and resize it if the request would be rejected.

Schematic illustration of check an image's size against vision model input limits: step one check the file size, step two count the images, step three resize if needed.

Vision models accept images in a request, but the request has limits: how large each image can be, and how many images one request can carry. Azure OpenAI, for example, allows 10 images per chat request. Check the size and count before sending, because a rejected request wastes the call and tells you nothing about the image itself.

Prerequisites

  • The image files you plan to send, with their sizes.
  • The provider’s documented limits for image size and count per request.
  • An image resizer, for the case a file is too large.

Steps

Step 1: Check the file size

Check each image’s file size and format. If a file is larger than the provider’s limit, resize it before sending; do not send it and hope.

Step 2: Count the images

Count the images in the request. If the count is over the limit, split the request into two, keeping the question with the images it needs.

Step 3: Resize if needed

Resize an oversized image to a smaller file, keeping the subject readable, and check the new size. A resized image that is too small to read is worse than a split request.

Worked example: Maple Corner bakery catalogue photos

The fictional Maple Corner bakery sends 3 catalogue photos to a vision model. The provider allows 10 images per request.

Image File size Readable after resize Action
Sourdough loaf 2.1 MB Yes Send as is
Rye loaf 4.8 MB Yes Send as is
Cake display 6.3 MB Yes Resize, then send

Two photos are sent as they are, and the 6.3 MB photo is resized first, so the request of 3 images stays within the limits.

Expected result. Every image in the request is within the size limit, and the image count is within the per-request limit. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • Size limits differ by provider; check the documentation for the provider you use, not a remembered number.
  • Resizing can blur small text in the image; check readability after resizing.
  • This guide does not cover the image formats accepted, which also vary by provider.

Sources

See all