r/Python • • Mar 26 '21

Tutorial How to extract text from image in Python

https://hinty.io/vserhiyev/how-to-extract-text-from-image-in-python/
25 Upvotes

8 comments sorted by

52

u/runew0lf Mar 26 '21

An entire blog post for a 3 line python script.

Is this is what this sub has come to?

Jeebus....

Let me spoil it for you so you dont have to click

from PIL import Image
import pytesseract  # Transforming image to string and printing it!
print(pytesseract.image_to_string(Image.open('test.png')))

9

u/GrowHI Mar 26 '21

I agree with you on this one. Trash post.

3

u/Bluprint Mar 26 '21

Yeah I'm kinda pissed because I received this post on like 2 or 3 different subs and it just seems like a lazy attempt to me to get some traction.

1

u/LirianSh Learning python Mar 26 '21

Sound complicated but its not

5

u/ES-Alexander Mar 27 '21

Any reason you used pytesseract instead of tesserocr, which is as good or better in practically every way?

1

u/[deleted] Mar 26 '21

I have implement a test automation framework for a legacy ERP system using opencv and tesseract. The text extraction in general is quite easy but when the text is small and have small space in-between, OCR fails.

1

u/Defiant-Cause-5704 Mar 27 '21

People come in and share the cool knowledge they gain, I think there is a room for explaining knowledge and logic even for a one line of code if it does something great