File Conversion

How to Extract Text from an Image: 8 Tips for Accurate OCR

We ran our free OCR tool on test images with tiny text, tilted lines, shadows and blur. Here is what really breaks text recognition, how to prepare a photo or screenshot, and how to check the result.

By Published 5 min read

Optical character recognition (OCR) turns the pixels of a picture into text you can copy, edit and search. It lets you take a quote from a screenshot, search a scanned letter or copy the amount from a photographed invoice. Modern OCR is very good on clean images and surprisingly fragile on poor ones. This guide shows which problems matter most, with measurements from our own Image to Text Converter (OCR).

How OCR works in your browser

Our tool uses Tesseract, an open-source OCR engine first developed at Hewlett-Packard between 1985 and 1994, open-sourced in 2005 and developed by Google from 2006 to 2017. Since version 4 it recognizes whole lines of text with a neural network (LSTM). The tesseract.js project makes it run inside a web browser.

When you start a recognition, the engine and the language data for English, German, Spanish or Persian are loaded from our server; your image itself is never uploaded. Before recognizing, the tool draws the image on a white background, so transparent PNGs work, and enlarges small images until the longer side is about 1,600 pixels, at most three times the original size. As the measurements show, that one step makes a big difference.

What we tested

We rendered the same short English text, an invoice note with a number, a date, an amount and a percentage, as images under different conditions and ran each one through the tool’s recognition. The score is character accuracy: the share of characters that matched the original after normalizing spaces, where 100% means a perfect result.

Dark text on white, Liberation Sans, PNG. Character accuracy with the English model.
Size of a lower-case “x”Image sizeAt original sizeEnlarged by the tool
4 px (8 px font)224 × 6029.9%89.1%
5 px (10 px font)280 × 7692.5%99.5%
7 px (12 px font)336 × 88100%100%
10 px (18 px font)504 × 136100%100%
19 px (36 px font)1009 × 272100%100%

Text whose lower-case letters were only 4 pixels high was almost unreadable at its original size; enlarging it raised the accuracy from 30% to 89%. Even then the engine read “1.28450” instead of “1,284.50”, exactly the kind of error that matters on an invoice. From about 7 pixels, our clean test images were recognized practically without errors. Published guidance for Tesseract is more cautious and calls an x-height of 20 to 40 pixels ideal, so for real-world images it pays to get closer or zoom in.

Each image recognized once with the tool’s default processing.
Condition (text with a 19 px x-height)Accuracy
Tilted 2°100%
Tilted 5°100%
Tilted 10°94.5%
Tilted 20°45.3%
Light gray text on white (#999)100%
Very light gray text on white (#ccc)100%
Light text on a dark background100%
Heavy random noise100%
Blurred (3-pixel Gaussian blur)89.6%
Shadow: brightness falling to 35% across the image64.7%
Small text (7 px) saved as JPG at quality 1096.5%

Three things hurt most: tilt beyond a few degrees, blur and uneven lighting. The shadow test is the most instructive. Tesseract silently skipped the darker part of each line and still reported a confidence of 95% for the text it did return. A high confidence score does not mean nothing is missing.

8 tips for better results

1. Make the text big enough

Move closer or zoom in instead of capturing a whole page from a distance. For screenshots, zoom the web page or document to 150–200% before you capture it. For scans, 300 dpi is the usual recommendation for normal print sizes.

2. Keep the lines straight

Up to 5° of tilt did no harm in our test, 10° cost a few percent and 20° made the result useless. Hold the phone parallel to the page. Turn sideways or upside-down images upright with the Rotate & Flip tool; for a slight tilt, take the photo again or straighten it in your phone’s photo editor.

3. Light the page evenly

Shadows from your hand or phone are the most common problem with photos of documents. Use daylight or two light sources, avoid flash reflections on glossy paper, and check the darker areas of the result first.

4. Crop to the text

Cut away the background, other columns and pictures with the Crop Image tool. Less clutter means fewer stray characters and a correct reading order, especially for pages with several columns.

5. Hold still and focus

Blur cost about ten percentage points in our test. Tap the screen to focus, rest your elbows on the table and take two photos if the first one looks soft.

6. Choose the right language

Select the language of the text before you start: the language model knows which letters and words to expect. For mixed documents choose a combination such as German + English or Persian + English. Persian text, with its connected letters, needs a clean, sharp image more than Latin script does; screenshots usually work well.

7. Prefer PNG for screenshots

JPG compression adds smudges around letters. Our heavily compressed test image (JPG at quality 10) still reached 96.5%, but every error is one you have to find. When you can choose, save screenshots as PNG, which is lossless.

8. Always check numbers and names

OCR mistakes look plausible: “1.28450” instead of “1,284.50”, a lower-case l instead of the digit 1, “rn” instead of “m”. Compare amounts, dates, account numbers and names with the original before you use the text.

Image to Text Converter (OCR)Extract text from images, screenshots and scans with OCR. Supports English, German, Spanish and Persian. Free, private, runs in your browser.Open tool

Screenshots, scans and photos compared

SourceTypical qualityWhat to watch out for
ScreenshotExcellent: sharp, straight, even contrastSmall font sizes; zoom in first
Scanner (300 dpi)Very goodDark borders at the edges, crooked pages
Phone photoVariesTilt, shadows, blur, curved pages

Privacy: why local OCR matters

The documents people run through OCR are often private: contracts, letters, ID cards, bank statements. Many online converters upload them to a server. Our Image to Text Converter (OCR) does all the work in your browser tab. Close the tab and nothing remains.

Tools used in this guide

Frequently asked questions

Can OCR read handwriting?

Only poorly. Tesseract is trained on printed text. Neat block capitals sometimes work; joined-up handwriting usually doesn’t.

Which languages does the tool support?

English, German, Spanish and Persian, plus combinations of German, Spanish or Persian with English for mixed documents.

Why are some lines missing from the result?

Usually because of uneven lighting, very small text or a busy background. In our shadow test, the engine skipped the darker part of each line without warning. Crop the image, improve the lighting and try again.

Does a high confidence score mean the text is correct?

No. The score describes the characters that were recognized, not those that were missed. Always compare important details with the original.

Is my image uploaded?

No. The image is processed in your browser; only the OCR engine and the language data are downloaded from our server.

Sources and further reading

  1. Tesseract OCR – README and history (GitHub) (github.com)
  2. Tesseract.js – Tesseract OCR in JavaScript (tesseract.projectnaptha.com)
  3. Tesseract documentation: Improving the quality of the output (tesseract-ocr.github.io)
  4. iDigBio: OCR tips (x-height and resolution) (www.idigbio.org)
All guides