MCPcopy
hub / github.com/lining0806/PythonSpiderNotes / image_to_string

Function image_to_string

Captcha1/pytesser_pro/pytesser_pro.py:28–38  ·  view source on GitHub ↗

Converts im to file, applies tesseract, and fetches resulting text. If cleanup=True, delete scratch files after operation.

(im, cleanup = cleanup_scratch_flag, bool_digits=False)

Source from the content-addressed store, hash-verified

26 errors.check_for_errors()
27
28def image_to_string(im, cleanup = cleanup_scratch_flag, bool_digits=False):
29 """Converts im to file, applies tesseract, and fetches resulting text.
30 If cleanup=True, delete scratch files after operation."""
31 try:
32 util.image_to_scratch(im, scratch_image_name)
33 call_tesseract(scratch_image_name, scratch_text_name_root, bool_digits)
34 text = util.retrieve_text(scratch_text_name_root)
35 finally:
36 if cleanup:
37 util.perform_cleanup(scratch_image_name, scratch_text_name_root)
38 return text
39
40def image_file_to_string(filename, cleanup = cleanup_scratch_flag, graceful_errors=True, bool_digits=False):
41 """Applies tesseract to filename; or, if image is incompatible and graceful_errors=True,

Callers 1

image_file_to_stringFunction · 0.85

Calls 1

call_tesseractFunction · 0.85

Tested by

no test coverage detected