How to extract text from an image: getting accurate OCR results

How optical character recognition works, how to photograph or scan documents for accurate results, and how to copy text from screenshots, photos and PDF scans.

Images2 min readUpdated

Key takeaways

  • OCR turns pictures of text into editable text; screenshots and clean scans give the best results.
  • Sharpness, size and contrast matter most: fill the frame with the text and avoid shadows and angles.
  • Scan at 300 dpi or more; very small letters are the most common cause of errors.
  • Always proofread, especially numbers, names and similar-looking characters.
On this page
  1. What OCR does
  2. Five ways to get better results
  3. Screenshots, photos and PDFs
  4. Check the result
  5. Privacy

What OCR does

Optical character recognition (OCR) looks at the shapes in an image, finds lines and words, and matches each shape to a letter. Modern engines such as Tesseract use a neural network (LSTM) trained on large amounts of printed text, which reads whole lines rather than single letters and copes well with ordinary fonts in many languages, including Arabic.

Five ways to get better results

  1. Get close. Fill the frame with the text you need. Small text is the most common cause of mistakes; Tesseract's documentation notes accuracy drops when letters are only a few pixels tall.
  2. Keep it straight and flat. Photograph the page from directly above, with the page flat. Curved book pages and angled shots distort the lines.
  3. Use even light. Avoid shadows from your phone or hand, and glare on glossy paper. Daylight near a window works well.
  4. Crop away clutter. Use crop image to remove backgrounds, other pages and photos, so the engine focuses on the text.
  5. Scan at 300 dpi or more when using a scanner, in greyscale or colour.

Screenshots, photos and PDFs

SourceTypical accuracyTip
Screenshot of a web page or appExcellentZoom in before taking the screenshot so the text is large
Flatbed scan of a printed pageVery good300 dpi, page straight on the glass
Phone photo of a documentGoodSteady hands, even light, fill the frame
Scanned PDFGoodConvert pages to images with PDF to JPG at 200–300 dpi first
HandwritingPoorOCR engines for print are not designed for handwriting

If a PDF contains real text (you can select it in a PDF reader), you do not need OCR at all: use PDF to text instead, which is exact.

Check the result

Even good OCR makes occasional mistakes: 0 and O, 1 and l, rn and m, and missing accents. Proofread anything you will rely on, especially figures, dates, names and account numbers. The image to text tool shows a confidence score; below about 60%, try a clearer image.

Privacy

Documents you photograph often contain personal details. Many online OCR services upload your image to their servers. Toolkeel's OCR runs entirely in your browser using WebAssembly, so the image stays on your device.

Sources

  1. Tesseract documentation: Improving the quality of the outputtesseract-ocr.github.io
  2. tesseract.js (open-source OCR in the browser)github.com
Written by the Toolkeel team at Sole Digital Media

Fact-checked against the sources above. We test every tool we mention. Editorial policy.