# How Do Images Become Tokens?

> How a photo is cut into patches, turned into vectors and counted as tokens, and why big pictures cost more, explained for your AI interview.

**In short:** An image has no words, so the model cuts it into small squares called patches and turns each one into a vector it can read. Anthropic counts each 28 by 28 pixel patch as one visual token, so bigger pictures cost more.

AI and LLM interview question Q442, Multimodal and newer topics. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/how-do-images-become-tokens

## Say it in 30 seconds

An image has no words, so the model cuts it into small squares called patches. Each square becomes a vector, a list of numbers the model can read, and people call that a visual token. Anthropic's docs say each patch covers 28 by 28 pixels, so bigger pictures cost more. Before I send a screenshot, I shrink it to the smallest size that still keeps the small text readable.

## Say it in 2 minutes

A language model works on numbers. Text is cut into tokens, and each token becomes a vector. A picture has no letters, so it needs its own route into those vectors. The usual route is to cut the picture into a grid of small squares, called patches, and turn each square into a vector.

Each square is flattened into a list of pixel values, and a learned map (numbers the model tunes during training) turns that list into one vector. A position tag is added too, so the model knows where each square sat. The model reads these image vectors in the same run as the text. Anthropic's docs call each patch a visual token, and say each one covers 28 by 28 pixels. The patch size is fixed, so the count depends only on the picture's pixel size. Two photos of the same size cost the same, whatever they show.

So the cost follows the size of the picture. Claude 4.7 and later models use the high-resolution tier, and the rest use the standard one. A picture costs its width divided by 28, rounded up, times its height divided by 28, rounded up. A 1,920 by 1,080 screenshot shrinks to 1,456 by 819 on the standard tier, which is 1,560 tokens. Kept whole on the high-resolution tier, it is 2,691.

Shrinking saves tokens, but small text can blur, so I test the smallest size that still reads the policy number before I ship it.

## What are image tokens, in plain words?

A language model works on numbers. Text is cut into tokens, small chunks of text that are often part of a word, and each token becomes a vector, a list of numbers that stands for it. A picture has no words, so it needs its own route into those vectors.

The usual route is to cut the picture into a grid of small squares, called patches. Each square is flattened into a list of pixel values, and a learned step (numbers the model tunes during training) turns that list into a vector. People call each of these image vectors a visual token.

Think of a claims adjuster who cuts a crash photo into numbered squares, logs what is in each one, and notes where it sat on the page. A claims app does the same with a photo of a dented bumper. The model gets a row of square vectors, each tagged with its position, and reads them beside the policy wording.

- **Patch:** A small square cut from the picture. Anthropic's docs use 28 by 28 pixels.
- **Visual token:** One patch, turned into a vector the model reads next to the text.
- **Patch embedding:** The vector a learned map makes from one flattened patch.
- **Position embedding:** A tag added to each vector that says where its square sat.
- **Downscale:** Shrinking a picture that is bigger than the model's limit, before it is read.

## How does a picture become a sequence of vectors?

The Vision Transformer paper from 2020, known as ViT, set out the basic recipe. A transformer is the model design behind modern chatbots, and ViT applies it to squares of a picture. Its abstract says that "a pure transformer applied directly to sequences of image patches can perform very well on image classification tasks". Its figure caption gives the steps in one line:

> "We split an image into fixed-size patches, linearly embed each of them, add position embeddings, and feed the resulting sequence of vectors to a standard Transformer encoder." (ViT paper, 2020)

1. **Cut the picture into squares:** The paper's title, "An Image is Worth 16x16 Words", hints at 16 by 16 patches. Anthropic's current docs use 28 by 28, so the size is a design choice.
2. **Flatten each square:** Each square is unrolled into one long list of numbers, one for each colour value in the square.
3. **Map each list to a vector:** A learned step, a simple multiply-and-add, turns each list into a vector of the size the model uses. The paper calls these the patch embeddings.
4. **Add a position tag:** Position embeddings are added so the model can tell where each patch sat. Without them, the model would not know which square sat where.

*Diagram, From a photo to tokens: A photo is cut into squares, each square is turned into numbers and then into a vector, and the model reads those vectors beside the text. The position tag tells the model where each square sat. The answer comes back as ordinary text.*
1. The picture goes in as a grid of coloured pixels.
2. Each square is flattened into one long list of numbers.
3. A learned map turns each list into a vector, with a position tag.
4. The model reads these vectors in the same run as the text.
5. It writes its answer as ordinary text.

The model then reads these vectors in the same run as the text, so the picture takes room from the same context window (the total text and images the model can read in one go). An example is LLaVA, a 2023 paper. It describes an "end-to-end trained large multimodal model that connects a vision encoder and LLM". Here multimodal means it handles pictures and text, and LLM means a large language model. Its authors say the model and code are publicly available.

## How many tokens does one picture cost?

Cost follows pixel size. What the picture shows does not change the count. Anthropic's docs give the rule: each patch covers 28 by 28 pixels, so the grid is the width divided by 28, rounded up, times the height divided by 28, rounded up. Each patch in that grid is one visual token.

> "Claude processes images in patches instead of pixels." (Anthropic)
>
> "keep in mind that images count as tokens and will be billed accordingly." (OpenAI)

Here is the rule in plain Python, with the two sizes from Anthropic's table.

```python
# Visual tokens for a picture: one 28 x 28 patch per token, rounded up at the edges.
import math

PATCH = 28

def visual_tokens(width, height):
    return math.ceil(width / PATCH) * math.ceil(height / PATCH)

# The model sees these sizes: the standard tier shrinks the screenshot first.
standard = visual_tokens(1456, 819)
high_res = visual_tokens(1920, 1080)

print("Standard tier, shrunk to 1456 x 819:", standard, "tokens")
print("High-res tier, kept at 1920 x 1080:", high_res, "tokens")
print("High-res costs", round(high_res / standard, 1), "times as much")
```

Output:

```text
Standard tier, shrunk to 1456 x 819: 1560 tokens
High-res tier, kept at 1920 x 1080: 2691 tokens
High-res costs 1.7 times as much
```

A claims team sends a 1,920 by 1,080 pixel screenshot of a crash report. Anthropic calls these size settings tiers. Claude 4.7 and later models use the high-resolution tier, and all other models use the standard tier. Here is the same screen on each tier. On the standard tier the model shrinks it to 1,456 by 819 first, which costs 1,560 visual tokens. Kept whole on the high-resolution tier, it costs 2,691. That is about 1.7 times as many tokens for the same screen.

*Diagram, One screenshot, two sizes: The same screenshot, two ways. Keeping it whole on the high-resolution tier gives more patches and more tokens, so fine detail costs more. The standard tier costs less, but the fine print may blur.*
1. Kept whole, the grid is 69 by 39 patches, so 2,691 tokens.
2. Shrunk first, the grid is 52 by 30 patches, so 1,560 tokens.

## What does shrinking a picture cost you?

Shrinking saves tokens, and the price is detail. Anthropic's guidance says a resize "might, for example, make text less legible", so a shrunk policy number can turn into a guess. High-resolution images can also use up to roughly three times more visual tokens than the same image on a standard tier, so the extra detail has a price.

- **Crop to the part that matters:** Send the damaged panel and the plate, not the whole street, so every token carries a useful detail.
- **Test the smallest readable size:** Try the real page or the real form at two or three sizes, and check that the policy number still reads.
- **Pay for the high tier only where it earns it:** Dense forms and small print can justify the extra tokens. A photo of a bumper usually does not need them.

> **Tip:** OpenAI's guide warns that a low detail setting does not always save tokens, so measure the count for your model instead of assuming.

### How would you cut the cost of a claims app that reads photos?

A claims app sends the photo again on every turn of the chat, because each request resends the earlier messages and images. Each resend counts toward that request's tokens, so the cost builds up over a long claim.

1. **Measure before you change anything:** Count the tokens for a typical claim photo with the width and height rule. Put a number on the problem first.
2. **Shrink to the smallest safe size:** Resize to the least size that still reads the policy number and the plate. Check it with real photos from the field, not clean test shots.
3. **Stop resending the photo:** Once the adjuster has the facts, a short written summary can stand in for the photo in later requests. The Files API keeps request payloads small, but the image still counts toward tokens.
4. **Track tokens per claim:** Log the token count for each claim, so one long chat with many photos shows up in the numbers.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Patches: the picture is cut into squares, and each square becomes a vector.
- [ ] Cost: width and height in 28 pixel steps, each rounded up, then multiplied.
- [ ] Shrinking saves tokens, but small text can blur.
- [ ] Limits and tiers differ by model, so check the current docs.
- [ ] Images share the context window with the text.
- [ ] A visual token here is a vector made from a patch, not an id from the text vocabulary.

**Common traps**

- Trap: "An image is just a file, so the model reads it like text." Better: It is cut into patches, and each patch becomes a vector the model reads next to the text.
- Trap: "Bigger pictures always give better answers." Better: Detail helps only up to the model's limit. Past it, the picture is shrunk anyway, so send the size that keeps the text readable.
- Trap: "A photo of a contract costs more tokens than a blank wall." Better: At the same size they cost the same. Cost follows the pixels.

## Can you spot the wrong count?

**Spot the wrong count:** Your team estimates the cost of a claims photo with Anthropic's rule. Which line counts its visual tokens correctly?

A. tokens = width * height
B. tokens = ceil(width / 28) * ceil(height / 28)
C. tokens = ceil(width / 16) * ceil(height / 16)

**Answer:** B. Anthropic's patches cover 28 by 28 pixels, not 16 by 16. A partial patch at the edge still counts, so round up on each side and multiply. Multiplying raw pixels gives a number far too large.

**Quick check:** A 1,920 by 1,080 screenshot goes to the standard tier, which shrinks it to 1,456 by 819. How many visual tokens does that cost?

A. About 2 million
B. 2,691
C. 1,560
D. 52

**Answer:** C. Shrunk to 1,456 by 819, the grid is 52 by 30 patches, so 1,560 tokens. Counting raw pixels gives about 2 million, and 52 is only the width of the grid.

## Can you answer these from memory?

**Flash cards**

- **What is a visual token?** One patch of the picture, turned into a vector the model reads with the text.
- **How is a picture cut up?** Into a grid of small squares called patches, such as 28 by 28 pixels.
- **What is a patch embedding?** The vector a learned map makes from one flattened patch.
- **What does a position embedding do?** Adds a tag to each patch vector, so the model knows where it sat.
- **How is the token cost counted?** Width and height each divided by 28 and rounded up, then multiplied.
- **Why shrink a big picture?** It saves tokens, but small text can blur, so test the readable size.

## Likely follow-up questions

- Q443 What is CLIP? https://designervenkat.online/interview/ai/what-is-clip
- Q072 What is a vision transformer? https://designervenkat.online/interview/ai/what-is-a-vision-transformer
- Q448 How do you extract structured data from documents and images? https://designervenkat.online/interview/ai/extract-structured-data-from-documents-and-images
- Q452 Native multimodal vs pipeline approach? https://designervenkat.online/interview/ai/native-multimodal-vs-pipeline-approach
- Q040 How do you estimate the token count of a text? https://designervenkat.online/interview/ai/how-do-you-estimate-the-token-count-of-a-text

## Learn it in depth

- [Image Understanding](https://designervenkat.online/learn/ai-engineering/image-understanding)
- [AI that sees, hears and reads](https://designervenkat.online/learn/ai-engineering/multimodal-ai)
