Topic 4 of 5 · 4 min read
Preparing images for accurate reading
Goal: Choose resize, crop and split settings that keep small print readable while keeping image token cost within a stated budget.
Give the model the smallest image in which the smallest text you care about is still easy to read. Too small and the text blurs. Too large and the provider resizes it for you, or you pay for pixels that add nothing.
Check yourself · 1 of 3
A phone photo of a page arrives sideways. What should happen before it is sent to a vision model?
Why it matters
Vision APIs turn an image into tokens, and the number of tokens grows with the image size. Most providers also cap the largest side and shrink bigger images before the model sees them. So a big photo of a full page may reach the model smaller than your own downscaled version, with the small print gone. Check each provider's docs for the exact limits and token formulas.
How to do it
- Fix the orientation. Rotate sideways and upside-down pages before sending. Models read rotated text worse.
- Fix contrast and skew. Straighten tilted scans and brighten faded ones. Convert colour to grayscale only if colour carries no meaning.
- Pick a target size. Work backwards from the smallest text. If body text should be about 20 pixels tall on the image, render a PDF page at a resolution that gives that, not more.
- Crop to regions. A header block, a table and a signature box can be separate crops. One question per region ("What is the total in this box?") is easier to check than one question about a whole page.
- Tile very large pages. Split a poster or a wide drawing into overlapping tiles so no line of text is cut in half. Merge the answers and remove duplicates from the overlap.
- Split multi-page files. One image per page, numbered, in order. Keep the page number in the prompt and in the output.
- Budget the cost. Count images and tokens per document from the provider's usage field on a sample, then multiply by volume.
Before and after
from PIL import Image
img = Image.open("scan.jpg") # 6000 x 8000 phone photo
img = img.rotate(-90, expand=True) # fix sideways page
img.save("page1.png") # sent as is
The photo is sent huge and sideways, and the provider shrinks it so small print blurs. After:
from PIL import Image, ImageOps
img = ImageOps.exif_transpose(Image.open("scan.jpg"))
img = ImageOps.autocontrast(img.convert("L"))
img.thumbnail((2000, 2000)) # cap the long side
total_box = img.crop((900, 1500, 1900, 1900)) # one region, one question
total_box.save("total.png")
What goes wrong
Downscaling erases a footnote, a tile cut splits a number in two, or a page is sent twice and counted twice. Always compare your preprocessed image with the original by eye.
Examples
A phone photo of a receipt
A 12-megapixel photo comes in sideways. The pipeline applies the EXIF rotation, converts to grayscale, caps the long side, and crops the totals area. The model reads the total from the crop. Token cost per receipt drops and the printed total is legible.
A wide engineering drawing
A drawing is split into four overlapping tiles. A dimension that straddles two tiles appears in both. The merge step keeps one copy by position. Without overlap, half of the dimension would be cut off at the tile edge and misread.
Key points
- Providers shrink large images and charge tokens by size, so send the smallest image where the smallest text is still readable.
- Fix rotation, skew and contrast before sending; models read tilted and faded text worse.
- Crop to regions and ask one question per region so each answer is easy to check.
- Tile very large pages with overlap, then merge answers and remove duplicates from the overlap.
- Measure token cost on a sample of real documents and multiply by volume before committing.
Common mistakes
- Sending the original full-resolution photo and assuming the model sees every pixel.
- Downscaling every page to a thumbnail to save cost, which erases the small print you need.
- Tiling without overlap, cutting numbers in half at the seam.
- Skipping rotation fixes because most pages are upright.
Check yourself · 2 of 3
Why can a huge photo of a full page lead to worse reading than a sensibly downscaled one?
Check yourself · 3 of 3
A tall engineering drawing is split into tiles. Why should the tiles overlap?
Practice items, not counted towards your mastery.
Start here
- Vision (Claude docs) (opens in a new tab)DocsFree
Image size limits, token cost per image, and tips for prompt placement and resizing.
- Document understanding (Gemini API) (opens in a new tab)DocsFree
How a model reads PDFs as pages and layout, with extraction examples and file limits.
- Images and vision (OpenAI docs) (opens in a new tab)DocsFree
Image input formats, detail levels and the stated limits of vision models.