How far to compress an image before it enters the model: tokens follow pixel size, not JPEG quality
Applies to gpt-6-astra vision input (detail accepts low, high, original or auto). The patch billing rules and defaults come from OpenAI's Images and vision guide, checked on 2026-12-02.
Phone screenshots, scanned pages, exported dashboards: the reflex is to shrink them before sending. But what to shrink, and how far, usually rests on two habits that no longer hold: that auto will fit the image under 2048 px for you, and that a lower JPEG quality saves tokens. On the current sizing table neither is true. Here is the arithmetic, then a measured A4 page to show where the text stops surviving.
The default is auto, and auto equals original
In the official sizing table, the four levels behave very differently for gpt-6-astra:
| detail | Behavior |
|---|---|
low | Fits within 512 x 512 |
high | Longest side up to 65,535 px, and at most 2,500 patches |
original | Keeps the original dimensions unless a side exceeds 65,535 px |
auto | Same as original |
Omitting detail gives you auto, so the default path does not downscale. A 4000 x 3000 phone screenshot needs ceil(4000/32) x ceil(3000/32) = 125 x 94 = 11,750 patches, times the model multiplier of 1.2, rounded up: 14,100 tokens. The same image under high is scaled to 1,250 x 938 (the 2,500-patch budget), roughly 3,000 tokens.
There is also a hard edge: a request whose processed image exceeds 30,000 patches is rejected, not silently shrunk to 30,000. When that happens the error surfaces as an image-dimension problem, and it is easy to misread as "the file is too big".
Worth checking the formula against the three official examples: 1024² gives 1,024 patches and 1,229 tokens, 2048² becomes 1,600² with 2,500 patches and 3,000 tokens, and 4096 x 512 stays put at 2,048 patches and 2,458 tokens. Recomputing with ceil(ceil(w/32) x ceil(h/32) x 1.2) matches all three.
Tokens follow pixel size only; JPEG quality is not in the formula
Patches are cut on a pixel grid, so how the file is encoded never enters the billing basis. One 1335 x 1888 image, saved four ways:
| Encoding | Size | Patches | Tokens | Character error rate |
|---|---|---|---|---|
| PNG | 153 KB | 2,478 | 2,974 | 4.0% |
| JPEG q85 | 91 KB | 2,478 | 2,974 | 4.0% |
| JPEG q60 | 72 KB | 2,478 | 2,974 | 4.8% |
| JPEG q40 | 65 KB | 2,478 | 2,974 | 3.6% |
q40 brings the file down to 42% of the PNG and removes exactly zero tokens; the error-rate movement sits inside the noise of a single page, so it is not evidence that harsher compression is more accurate. The conclusion is blunt: use JPEG to cut bytes, change dimensions to cut tokens. The former affects upload time, base64 payload and timeout odds; only the latter reaches the invoice.
One A4 page, measured: 512 loses everything, 1024 is the floor
The test target is a synthetic A4 Chinese document at 200 dpi (1,654 x 2,339 px): 12 lines, 250 effective characters, with order numbers, amounts and dates. Each tier was scaled by the official dimension and patch-budget rules with LANCZOS resampling, then read by tesseract 4.1.1 (chi_sim, psm 6) and scored as character error rate. Environment: Python 3.12.11, Pillow 10.4.0, sample size one page.
| Tier | Size after scaling | Patches | Tokens | Character error rate |
|---|---|---|---|---|
| low equivalent (512) | 362 x 512 | 192 | 231 | 100.0% |
| longest side 768 | 543 x 768 | 408 | 490 | 84.8% |
| longest side 1024 | 724 x 1,024 | 736 | 884 | 15.6% |
| high budget | 1,335 x 1,888 | 2,478 | 2,974 | 4.0% |
| no scaling | 1,654 x 2,339 | 3,848 | 4,618 | 4.4% |
Three conclusions you can act on:
lowis unreadable for small Chinese body text. The 512 tier costs 231 tokens and misses 100% of characters — not "a bit blurry", but the whole page.lowanswers "what is this image roughly", not "what does it say".- The knee sits near 1024, not 2048. At 768 eight characters in ten are still wrong, at 1024 the rate drops to 15.6%, and at the high budget (about 2,478 patches) only 4.0% remains.
- More pixels past that buy no accuracy. Not scaling costs 55% more tokens than the high budget and scores 0.4 points worse — at this size the extra pixels are noise.
Note that this is OCR error rate, a measure of whether the glyphs still exist at the pixel level, and therefore a lower bound on what a model can read: what tesseract cannot resolve, a model will not resolve either; what tesseract resolves, a model may still misread. For the model's own accuracy, run a second round on your business samples instead of treating this table as model accuracy.
Size by patch budget, not by a favorite long edge
Rather than remembering "shrink to 1024", derive the scale from the patch budget so the same snippet holds for any input size:
import math
from PIL import Image
BUDGET, MULT = 2500, 1.2 # gpt-6-astra: 2500 patches at high, multiplier 1.2
img = Image.open(src); w, h = img.size
if math.ceil(w/32) * math.ceil(h/32) > BUDGET:
sf = math.sqrt(32**2 * BUDGET / (w*h)) # simplified form of the official scaling rule
nw, nh = int(w*sf), int(h*sf)
img = img.resize((nw, nh), Image.LANCZOS) # resize first, save after
img.save(dst, "JPEG", quality=80) # bytes go to quality, pixels go to the patch budgetThree rules that go with it:
- Count patches before choosing a tier. Estimate tokens as
ceil(patch x 1.2)and multiply by the input price to see what the image is worth; for document images below roughly 1,000 tokens, do not expect small text to survive. - Do not use
lowfor text-dense images. The official limitations page says to enlarge small text and to useoriginalwhere available. For coordinate work (OCR boxes, clicking) useoriginal, downscale yourself within the pixel limits, and map returned coordinates back to the original image. autois not a safe fallback. It equalsoriginalongpt-6-astraand also on thegpt-5.6family; if you want cost control, writehighexplicitly or resize yourself.
One line to close: bytes to JPEG, pixels to the patch budget, tier written explicitly — three separate levers for transfer, invoice and legibility. Mix them up and you pay more for a worse read.