Tesseract Invalid resolution: the warning is not the problem
The warning changed nothing. The dpi did:
4 of 63
invoice numbers with a silent 72 dpi tag
Our Actor: Markdown at $0.006 a scanned page
Runs on Apify's servers: files leave your computer.
Which file prints which message
| The file | Tesseract prints |
|---|---|
| No dpi in the file | Estimating resolution as 636 |
| A dpi over 70, up to 2400 | Nothing |
| Under 70 or over 2400, such as 1 |
Warning: Invalid resolution 1 dpi. Using 70 instead.Estimating resolution as 636
|
--psm 0 or image_to_osd, no dpi |
Estimating resolution as 636Warning. Invalid resolution 0 dpi. Using 70 instead.
|
"Using 70 instead" is not final: 70 means unknown, so Tesseract then guesses. A file or flag of exactly 70 does too.
The 0 dpi line comes from orientation detection
Only orientation detection prints it (--psm 0, or
pytesseract's image_to_osd), with a period after Warning.
--dpi does not stop it; a dpi stored in the file does:
$ tesseract page.png out --psm 0 --dpi 300
Warning. Invalid resolution 0 dpi. Using 70 instead.
- The orientation answer was the same with or without it.
- Tesseract 5.0.0 hid it in plain OCR (PR #3342); version 4 printed it for every file with no dpi.
Prose did not change. Tables did.
Full-size invoices scanned at 300 dpi: numbers read, of 63
Book pages: 391 of 399 words in all three cases.
- The 72 tag is the trap: no message, and most numbers vanished from the text.
-
At half size the tag did not matter. At quarter size,
--dpi 300read 0 numbers on one invoice; its real dpi read 5.
Fixes that worked, and two that failed
On the untagged invoice (2 of 33 numbers), Yes means 30 or more:
| Fix | PNG | JPEG |
|---|---|---|
--dpi 300 |
Yes | Yes |
Pillow im.save(path, dpi=(300, 300)) |
Yes | Yes |
magick -units PixelsPerInch -density 300 |
Yes | Yes |
sips -s dpiWidth 300 -s dpiHeight 300 |
Yes | No, 3 of 33 |
exiftool -XResolution=300
-YResolution=300
-ResolutionUnit=inches
|
No, 2 of 33 | Yes |
sips left a JPEG's density units at 0. exiftool's XResolution gave a PNG EXIF only; Tesseract reads pHYs:
exiftool -PNG:PixelsPerUnitX=11811 \
-PNG:PixelsPerUnitY=11811 \
-PNG:PixelUnits=meters in.png
pytesseract drops the dpi of a PIL image
It saves a PIL PNG or JPEG to a temp file with no dpi, even a 300 dpi one:
pytesseract.image_to_string(img, config="--dpi 300")
- Or pass the file path instead.
- A TIFF kept its dpi. A PPM page, pdf2image's default, has no dpi field.
- pytesseract shows Tesseract's warnings only when Tesseract fails, so a working script hides them.
OCRmyPDF stops instead: DpiError, exit 2
OCRmyPDF 17.13.0, on an image with no dpi:
DpiError: Input file is an image, but has no resolution (DPI) in its metadata. Estimate the resolution at which image was scanned and specify it using --image-dpi.
Or any dpi up to 96, such as a 72 tag:
DpiError: Input file is an image, but the resolution (DPI) is not credible. Estimate the resolution at which the image was scanned and specify it using --image-dpi.
- A phone JPEG with 72 only in EXIF gets it too, though Tesseract reads it as no dpi: JFIF only.
- The fix read 197 of 202 words:
ocrmypdf --image-dpi 300 page.png out.pdf
Our Actor read every table number
A local run of its code. It trusts a stored dpi only from 70 to 1200; else it guesses from page size and text height.
63 of 63 table numbers, full and half size, any tag
2 words lost to a 72 tag, one prose page
22 to 43% slower with a 72 tag than with none
Tesseract always reads the text at --dpi 300, so it never
guesses a dpi. Digital PDF pages are free.
What I did not test
- Real low-dpi scans or phone photos: I made both from scans.
- pdf2image itself: not installed, so I copied its default.
- The live Actor on Apify, or other Tesseract versions.
How I tested it
- Pages: 2 proofread scanned book pages, 1920 px JPEGs with 399 true words, and 2 invoice scans, 2550 x 3300 px at 300 dpi, with 63 numbers.
- Each also at 50% and 25%, box filter, gray PNG. The right dpi there is 150 and 75.
- Score: book words found in order. An invoice number counts only if the word read in its row is the printed text.
- With no dpi, one invoice still had 25 numbers in the text, but in column blocks, out of their rows.
- Every file's tags were read back with exiftool, sips and Pillow. Every Tesseract run was alone, on 1 thread.
- The Actor: its code from our repo, run on this Mac with 1 GB of memory, 21 runs.
- Versions: Tesseract 5.5.4 with Leptonica 1.87.0, OCRmyPDF 17.13.0, pytesseract 0.3.13, Pillow 12.3.0, ImageMagick 7.1.2-11, exiftool 13.44, macOS 26.6.
- Scripts and results stay in our private repo, in research/bench/tesseract-invalid-resolution-2026-11-24/.
Sources
- Tesseract baseapi.cpp: the colon warning, skipped when the dpi is 0
- Tesseract osdetect.cpp: the period warning, with no check for 0
- Tesseract pagesegmain.cpp: Estimating resolution as
- Leptonica jpegio.c: JPEG dpi from JFIF only
- pytesseract.py: the temp file is saved with no dpi
- OCRmyPDF _pipeline.py: the two DpiError checks
- We make the Apify Actor, and none of the other tools here.
Questions people ask
What does Invalid resolution 0 dpi mean?
The image has no dpi, so Tesseract uses 70. In Tesseract 5.5.4 only orientation detection prints it: --psm 0, or image_to_osd in pytesseract. --dpi does not stop it there; a dpi stored in the file does. The orientation answer was the same.
What does Estimating resolution as mean?
Tesseract found no usable dpi, so it guessed one from the size of the text: 636 on a book page. On 2 invoices at 300 dpi, working from that guess read 9 of 63 numbers. With --dpi 300 it read 60.
How do I fix Invalid resolution in pytesseract?
pytesseract saves a PIL PNG or JPEG without its dpi. Pass the real value, as in config="--dpi 300", or pass the file path. For image_to_osd, --dpi did not stop the 0 dpi line; on the command line, a file with its dpi stored did.
Does Invalid resolution hurt OCR accuracy?
The message does not: the same pixels gave the same text with and without it. The dpi does: on 300 dpi invoices, no dpi read 9 of 63 numbers, a silent 72 tag 4, and the right dpi 60. Book pages did not change.
Two ways to skip the work
Run it yourself. Our Apify Actor turns scanned PDFs and images into Markdown, in the cloud.
Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free.