LevelUpWith

Explore / Multimodal AI Engineering: Vision to Production / Lesson 2

Lesson 2: Resolution, Tiling and the Image Token Budget

Learn how providers resize, tile or dynamically size images, and how that choice fixes both the fine detail a model can see and what you pay for each image.

Free to read, no account needed. Part of Multimodal AI Engineering: Vision to Production.

By the end of this level you'll be able to

  • Work out the image tokens and cost per image for a given resolution under at least two providers' documented rules
  • Run the same detail-heavy question at several resolutions or detail settings and chart accuracy against tokens
  • Pick a resolution policy for a workload and back it with measured numbers

Why resolution is a product decision

In Level 1 you saw that a vision-language model cuts an image into small square patches and turns each one into an embedding, an image token. This level asks the follow-up you will face on your first invoice: how many patches does my image become, and who decides?

You don't fully decide. Every provider runs your image through its own sizing rules before the model sees it. It scales down large images, sometimes caps the patch count, and sometimes ignores pixel count altogether. Those rules settle two things at once:

  1. What the model can see. If a 4K screenshot gets shrunk to 1456×819, 9‑pixel footnote text drops to about 3 pixels. No prompt can bring it back.
  2. What you pay. Image tokens are billed as input tokens, so the patch count multiplied by the price per token gives your cost per image.

Think of it as a fixed-size viewfinder. A bigger photo doesn't give you more detail. It gets squeezed to fit the frame.

Three sizing styles you will meet

1. Patch counting with a cap (Anthropic Claude). Claude counts 28×28-pixel patches: ceil(w/28) * ceil(h/28). Each model has a long-edge limit and a token limit, and anything larger is shrunk with its aspect ratio kept:

Tier Models Max long edge Max visual tokens
High-resolution Claude 4.7 and later 2,576 px 4,784
Standard older models 1,568 px 1,568

2. Patch counting with detail levels and a multiplier (OpenAI's newer models). For patch-based models such as gpt-5.5, the image is first fitted to the limit for the detail level you chose. Then 32×32 patches are counted, a patch budget is applied, and the count is multiplied by a model-specific factor (1.2 for gpt-5.5). For gpt-5.5, low fits the image within 512×512. high allows up to 2,500 patches and a 2048 px maximum side. original allows up to 10,000 patches and a 6000 px maximum side. Older tile-based models (gpt-4o, gpt-4.1) use a different formula: base tokens plus 170 tokens per 512 px tile.

3. A fixed budget per setting (Google Gemini 3). You choose a media resolution level for each image, and the token budget comes from the level, not from the pixel count: low 280, medium 560, high 1120 (the default), ultra_high 2240. Google recommends high for most image work and medium for PDFs, where OCR quality usually stops improving at medium.

Gotcha: don't assume low is cheaper. For OpenAI's gpt-5.4, low uses a 2048 px side and a 6,144-patch budget, and the docs warn that it can cost more than high. Check the table for your exact model.

Walkthrough: a token and cost estimator

import math

def fit(w, h, max_side):
    """Shrink (never enlarge) so the longest side <= max_side, keeping aspect ratio."""
    s = min(1.0, max_side / max(w, h))
    return int(w * s), int(h * s)

def claude_tokens(w, h, max_edge=2576, max_tok=4784, patch=28):
    w, h = fit(w, h, max_edge)
    tok = lambda a, b: math.ceil(a / patch) * math.ceil(b / patch)
    while tok(w, h) > max_tok:           # shrink until under the token cap
        w, h = int(w * 0.99), int(h * 0.99)
    return tok(w, h), (w, h)              # an estimate: the API's exact resize can differ by a few tokens

def openai_patch_tokens(w, h, max_side=2048, budget=2500, mult=1.2, patch=32):
    w, h = fit(w, h, max_side)            # step 1: fit to the detail level's pixel limit
    p = lambda a, b: math.ceil(a / patch) * math.ceil(b / patch)
    while p(w, h) > budget:               # step 3: apply the patch budget
        w, h = int(w * 0.99), int(h * 0.99)
    return math.ceil(p(w, h) * mult), (w, h)  # step 5: apply the multiplier

for size in [(1000, 1000), (1920, 1080), (3840, 2160)]:
    print(size,
          "claude-hi:", claude_tokens(*size)[0],
          "claude-std:", claude_tokens(*size, 1568, 1568)[0],
          "gpt-5.5 high:", openai_patch_tokens(*size)[0],
          "gpt-5.5 low:", openai_patch_tokens(*size, max_side=512)[0])

Realistic output, which matches the providers' published examples:

(1000, 1000)  claude-hi: 1296  claude-std: 1296  gpt-5.5 high: 1229  gpt-5.5 low: 308
(1920, 1080)  claude-hi: 2691  claude-std: ~1560 gpt-5.5 high: 2448  gpt-5.5 low: 173
(3840, 2160)  claude-hi: 4784  claude-std: ~1560 gpt-5.5 high: 2765  gpt-5.5 low: 173

To get money, multiply by the price per token. At Claude Opus 5.5's listed $4 per million input tokens, a 1000×1000 image (1,296 tokens) costs about $5.18 per thousand images, and a 4K frame (4,784 tokens) about $19.14 per thousand. A Gemini 3 image at high is 1,120 tokens whatever its size. Look up prices on each provider's pricing page on the day you decide, because they change.

Best practice: don't rely on the estimator for billing. Log the usage input-token count the API returns for every call and compare it with your estimate. Developers have reported counts that differ from the documented rules.

Measure, don't guess: accuracy against tokens

More tokens only help if your question depends on detail that would otherwise be lost. Reading a total off a receipt might be perfect at 560 tokens. A serial number in 8 pt text might need 2,500. The only honest way to choose is a sweep:

# ask(image_bytes, question) -> (answer, input_tokens). Write it with any SDK for now; Level 4 builds a proper client.
from PIL import Image
import io

def sweep(path, question, truth, sides=(512, 768, 1024, 1568, 2048)):
    rows = []
    for side in sides:
        img = Image.open(path)
        img.thumbnail((side, side))         # you control the size, not the provider
        buf = io.BytesIO(); img.save(buf, "PNG")
        answer, tokens = ask(buf.getvalue(), question)
        rows.append((side, tokens, answer.strip() == truth))
    return rows

Run it over 20–50 images rather than one, and plot the share answered correctly against the average number of tokens. You will usually get a curve that rises steeply and then flattens. Your policy is the cheapest setting on the flat part, plus a margin.

Hands-on exercise

  1. Pick 20 detail-heavy images from your own domain: invoices, screenshots, product labels. Write one question per image with a known answer.
  2. Estimate tokens and cost per image for two providers using the functions above.
  3. Run sweep at five sizes (or detail levels) on one provider and log the actual usage tokens.
  4. Chart accuracy against tokens. Write a one-paragraph resolution policy, for example: "1568 px long edge, ~1,560 tokens, 95% accuracy, $X per 1k images; going to 2048 px adds 2% accuracy for +60% cost."

Key takeaways

  • Providers resize, cap or fix a budget for every image. That single step decides both the detail the model can see and your cost.
  • Claude counts 28 px patches under a long-edge and token cap. OpenAI's patch models count 32 px patches, apply a budget, then a multiplier. Gemini 3 uses a fixed budget for each resolution level.
  • "Low" isn't always cheaper. Read the table for your exact model.
  • Estimate with code, then check against the usage tokens the API returns.
  • Pick your resolution from a measured accuracy-against-tokens curve, not from a default setting.

A 6-question knowledge check follows this lesson in the app, free and without an account.

Keep going: levels 3 and 4 are free

Create a free account to open the next two levels, try the AI tutor, save your progress and pick up where you left off. No card needed.

Next: Level 3, Image Preprocessing That Changes Answers.

Create a free account →See the whole course

More like this