Python Forum
write image into string format into text file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
write image into string format into text file
#1
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)
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  code decode, string, image ... teckow 2 227 Aug-20-2021, 07:02 PM
Last Post: teckow
  How to write in text file - indented block Joni_Engr 3 312 Aug-09-2021, 06:30 PM
Last Post: deanhystad
  Replace String in multiple text-files [SOLVED] AlphaInc 5 514 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
  fuzzywuzzy search string in text file marfer 9 465 Aug-03-2021, 02:41 AM
Last Post: deanhystad
  How can we transcode encoding file uml url format Anldra12 9 503 Jul-25-2021, 09:30 AM
Last Post: Anldra12
  Read and write active Excel file euras 4 510 Jun-29-2021, 11:16 PM
Last Post: Pedroski55
  string.format() suddenly causing errors with google drive API zwitrader 0 265 Jun-28-2021, 11:38 PM
Last Post: zwitrader
  Read file, reformat and write new file bryanmartin113 1 494 Jun-08-2021, 09:27 PM
Last Post: Larz60+
  How to design a save file format? philipbergwerf 5 1,048 Apr-26-2021, 07:39 PM
Last Post: Gribouillis
  String to Date format SAF 2 667 Apr-06-2021, 02:09 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020