Skip to content
mentoor

Topic 2 of 4 · 4 min read

Preparing images for vision requests

Goal: Resize, crop and label images in a vision request so it stays within the token budget and the model can tell them apart.

Send the smallest image that still shows what the question needs, in a supported format, with a short text label on each one. More pixels do not mean better answers. They mean more tokens, and beyond a limit the provider shrinks the image for you.

Check yourself · 1 of 3

You need the model to read one printed serial number from a large photo. What is the best preparation?

Choose one answer

Why it matters

Image cost scales with size. Claude's guide says an image costs about ⌈width / 28⌉ × ⌈height / 28⌉ visual tokens, with a ceiling per model: 1,568 tokens and a 1,568 px long edge on the standard tier. A phone photo larger than that is downscaled anyway, so uploading it at full size wastes bandwidth and can make small text unreadable after the resize.

How to prepare an image

  1. Use a supported format. Claude accepts JPEG, PNG, GIF and WebP. A GIF is read as its first frame only.
  2. Resize to the model's limit. Resize on your side so you control the result. Long edge near 1,568 px is enough for the standard tier.
  3. Crop to what matters. To read one field on a receipt, send that region, not the whole table. The crop keeps text large after any resize.
  4. Compress with care. Heavy JPEG compression blurs small text. Inspect the image you actually send.
  5. Label several images. Introduce each with text such as Image 1: front of the box so your prompt and the answer can refer to them by name.
  6. Order matters a little. Claude's guide says it works best with images before the text.

Before and after

# Weak: 6000x4000 photo, no label, question first
content = [
    {"type": "text", "text": "What is the serial number?"},
    {"type": "image", "source": img_full},
]
# Better: crop the label area, shrink, label, question last
from PIL import Image
im = Image.open("box.jpg").crop((1800, 2600, 3400, 3100))
im.thumbnail((1568, 1568))
im.save("label.jpg", quality=90)
content = [
    {"type": "text", "text": "Image 1: serial label on the box"},
    {"type": "image", "source": b64_source("label.jpg")},
    {"type": "text", "text": "Read the serial number from Image 1."},
]

What goes wrong

  • Tiny images. Claude's guide warns of mistakes on low-quality, rotated or very small images under 200 pixels.
  • Unlabelled sets. With five unlabelled photos, "the second one" is a guess.
  • Cropping too tight. Cut the context a value depends on, such as a column header, and the reading becomes ambiguous.

Examples

Cropping a receipt total

A 4000x3000 photo of a till receipt is sent to read one number, the total. After the provider's downscale the digits are about 10 px tall and the model reads 8.40 as 6.40.

Crop to the bottom third and send it near 1,500 px wide. The digits are now large, the token cost is lower, and the answer can be checked against the cropped image.

Comparing two screenshots

content = [
    {"type": "text", "text": "Image 1: checkout page before the change"},
    {"type": "image", "source": before},
    {"type": "text", "text": "Image 2: checkout page after the change"},
    {"type": "image", "source": after},
    {"type": "text", "text": "List visible differences between Image 1 and Image 2."},
]

Key points

  • Cost grows with image size, and images beyond a model's long-edge or token limit are downscaled before the model sees them.
  • Claude accepts JPEG, PNG, GIF and WebP; a GIF contributes only its first frame.
  • Crop to the region the question needs so small text stays large after any resize.
  • Heavy lossy compression makes text hard to read, so inspect the exact bytes you send.
  • Introduce each image with a short text label so the prompt and answer can refer to it by name.

Common mistakes

  • Uploading full-resolution photos and letting the provider downscale them, which costs bandwidth and can blur the text you need.
  • Sending several images with no labels and then asking about "the second one".
  • Compressing a screenshot to heavy JPEG, which smears small text, instead of using PNG or higher quality.
  • Cropping out the header or legend a value depends on.

Check yourself · 2 of 3

How should you identify several images in one request?

Choose one answer

Check yourself · 3 of 3

A 5000x3000 JPEG of a form is sent as-is and the model misreads small digits. The long-edge limit is 1,568 px. What explains it?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic