Tools,

Tesseract reads white text. Two things broke it

96.3%

words right on white on black, no prep

Black on white: 96.1%. No need to invert.

See the two traps

Dark color sets read like black on white

The same two paragraphs drawn four ways: dark gray on white, white on black, a dark band over a white page, and white on a transparent background shown on a gray checkerboard.
Block 1 in 4 of the 8 color sets, at 2x. The checkerboard marks the transparent PNG.
Words right, Tesseract 5.5.4, screenshots at 1x
Colors As it is Invert flag off
Black on white (the control) 96.1% 96.1%
White on black 96.3% 0.5%
Light gray on dark gray (code editor) 96.4% 0.7%
Gray on near black 96.3% 0.8%
White on blue 96.3% 1.4%
White on green 96.3% 1.2%
Dark band over a white page 96.4% 41.6%
White on transparent 14.9% 14.9%

Each row is the same 591 words in 10 screenshots. Only the colors change.

At 2x, every row but the transparent one read 96.6%.

Trap 1: the invert flag set to 0

tesseract shot.png - \
  -c tessedit_do_invert=0

The Tesseract FAQ suggests this flag for speed. On white on black it printed junk, with no error:

Tee ee Case aura eeu hea ee Cont uke Cee euls|

Invert it yourself and keep the flag? No

I inverted each shot whose mean gray was under 128, then ran the flag. Two color sets failed:

Tesseract decides line by line, so it got both right. All 6 dark sets together: 74.1% with this trick, 96.3% with no flag.

Trap 2: white text on a transparent PNG

A logo, a cutout or a caption layer often has no background. Tesseract read 14.9% of those words, and 33.2% at 2x. On one shot it printed:

Talat et ister Sireret thet night, ard me mae engaged Upan our taeet ard

Put it on black first:

magick shot.png -background black \
  -flatten flat.png
tesseract flat.png -

Flattened on black, the 10 shots read 96.1%, as good as black on white.

Flattened on white, they read 0 words. A gray copy, which drops the transparency, read 82.9% after inverting.

The same fix in Python

from PIL import Image
import pytesseract

img = Image.open("shot.png").convert("RGBA")
black = Image.new("RGBA", img.size, "black")
print(pytesseract.image_to_string(Image.alpha_composite(black, img)))

As printed, on one transparent shot: 59 of 60 words right, as with magick.

Inverting first gained nothing

Words right on the 6 dark color sets, 1x
Step before Tesseract Words right
None 96.3%
Invert every shot 96.2%
Invert if the mean gray is under 128 96.2%
Otsu black and white 94.8%
-c invert_threshold=1 96.3%

Our Actor reads dark screens, not clear PNGs

PDF OCR to Markdown, our Apify Actor, takes PNG files too. On 3 blocks of each color set, it read 97.8% of words on all 7 opaque sets.

It read nothing on the transparent shots: it puts them on white, so white text disappears. Flatten them on black first. A fix is on our list.

What I did not test

How I tested it
  • Text: 10 blocks of 56 to 65 words from The Adventures of Sherlock Holmes (1892, public domain), from Wikisource. 591 words in all.
  • Shots: headless Chromium drew each block at 14 px, 560 px wide, at 1x and 2x. 8 color sets, the same blocks in each. 160 PNG files.
  • Colors: #222 on #fff, #fff on #000, #d4d4d4 on #1e1e1e, #8e8e93 on #1c1c1e, #fff on #0a84ff, #fff on #34c759, a #1e1e1e band over #fff, and #fff on transparent.
  • Tesseract: the command line, default page mode, English tessdata_fast 4.1.0, one thread, one run at a time.
  • Words right: words that match the text, in any order, with case and punctuation kept.
  • The Actor: its own code at commit 5dcdaa5f, run on this Mac on blocks 1 to 3 of each set at 1x, with text output.
  • Each tesseract, magick and Python command on this page ran as printed.
  • Tesseract 5.5.4 (Leptonica 1.87.0), ImageMagick 7.1.2-11, Chromium 153.0.8010.12, Pillow 12.1.1 (13.0.0 for the Python code), pytesseract 0.3.13, Python 3.14.7, macOS 26.6 (arm64).
  • Scripts and results stay in our private repo, in research/bench/tesseract-white-text-2026-11-23/.
Sources

Questions people ask

Can Tesseract read white text on a black background?

Yes. Tesseract 5.5.4 read 96.3% of the words on our white on black screenshots with no prep, and 96.1% on the same text in black on white.

Should I invert the image before Tesseract?

Not for a dark screenshot. Inverting first read 96.2% of words on our 6 dark color sets, against 96.3% with no step. Tesseract tries an inverted copy of each weak line on its own.

Why does Tesseract print junk for white text?

Look for -c tessedit_do_invert=0 or -c invert_threshold=0 in your command or config. With either, white on black read 0.5% of words, and Tesseract printed junk with no error. Delete the flag.

How do I OCR white text on a transparent PNG?

Put it on black first: magick shot.png -background black -flatten flat.png, then tesseract flat.png -. As it was, Tesseract read 14.9% of the words. Flattened, it read 96.1%.

Two ways to skip the work

Run it yourself. Our Apify Actor turns scanned PDFs and images into Markdown, tables included.

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