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

Tesseract 5.5.4 on a scanned book page, exact
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 636
Warning. 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.

Prose did not change. Tables did.

Full-size invoices scanned at 300 dpi: numbers read, of 63

No dpi: Tesseract guessed 9

A 72 dpi tag: no message 4

The right dpi, or --dpi 300 60

Book pages: 391 of 399 words in all three cases.

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")

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.
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

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

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.

Try the Actor

Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free.

Get one page free