Python Forum
write image into string format into text file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: write image into string format into text file (/thread-18798.html)



write image into string format into text file - venkat18 - Jun-01-2019

To write image file into text format using pytesseract.image_to_string, I am using below code. It is only writing last lne of the image into out file, instead of entire data.

try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract
# Simple image to string
text=print(pytesseract.image_to_string(Image.open('test.jpg'),lang="eng"))
with open('out.txt', 'w') as f:
    print(text, file=f)



RE: write image into string format into text file - buran - Jun-01-2019

is that you, recent post on SO:
https://stackoverflow.com/q/56404380/4046632

or just a coincidence? check the last answer https://stackoverflow.com/a/56404405/4046632


Now, I see you, crossposted at SO
https://stackoverflow.com/q/56404452/4046632


RE: write image into string format into text file - venkat18 - Jun-01-2019

Thank you! It helped. I was having "print" even though i am writing file.