How to Extract Text from Images Using OCR in Python (With Tesseract & EasyOCR)
Technology Posts

How to Extract Text from Images Using OCR in Python (With Tesseract & EasyOCR)

Aashish Kasma|April 8, 2025|1 Minute read|Listen
TL;DR

Turning photos and scanned documents into editable text with OCR in Python. What OCR is, how Tesseract and EasyOCR compare, and a worked example extracting text from an invoice.

Looking for a way to turn photos or scanned documents into real, editable text? Welcome to the world of OCR — Optical Character Recognition.

What is OCR?

OCR helps you extract machine-readable text from images. From scanning invoices to digitizing receipts or reading license plates — it automates it all.

Best Python Libraries for OCR

  • pytesseract – A Python wrapper for Google’s Tesseract engine.
  • EasyOCR – Built for deep learning-based OCR with multilingual capabilities.

How to Set Up OCR in Python

Install dependencies:

pip install pytesseract easyocr pillow

Code Example – Extracting Text from an Invoice

Using Tesseract:

`from PIL import Image import pytesseract

text = pytesseract.imagetostring(Image.open('invoice.png')) print(text) `

Using EasyOCR:

`import easyocr

reader = easyocr.Reader(['en']) results = reader.readtext('receipt.jpg') for result in results: print(result[1]) `

Detect Multilingual Text

Both tools support multiple languages.

pytesseract : Use lang='eng+hin'

easyocr : Use Reader(['en', 'hi', 'fr'])

Use Cases

  • Scan invoices and extract payment details
  • Parse printed receipts for inventory apps
  • Read license plates from traffic cams
  • Translate text from foreign signage

Final Thoughts

OCR is a powerful tool for digitizing real-world content. Whether you’re automating backend tasks or building AI-based systems, tools like Tesseract and EasyOCR make it simple.

Want to build your own document reader or smart scanner? Start with these libraries and add AI for context-aware enhancements.

SHARE

Aashish Kasma
Aashish Kasma
Co-founder & CTO, Lucent Innovation
linkedinmediumdevtohashnode

Facing a Challenge? Let's Talk.

Whether it's AI, data engineering, or commerce tell us what's not working yet. Our team will respond within 1 business day.

Start the Conversation

Frequently Asked Questions

Still have Questions?

Let’s Talk

What is OCR and what is it used for?

arrow

Should you use Tesseract or EasyOCR in Python?

arrow

How do you extract text from an image in Python?

arrow

Can OCR handle more than one language at a time?

arrow