def image_file_to_string(filename, cleanup=cleanup_scratch_flag, graceful_errors=True, bool_digits=False):
 try:
  call_tesseract(filename, scratch_text_name_root, bool_digits)
  text = util.retrieve_text(scratch_text_name_root)
 except errors.Tesser_General_Exception:
  if graceful_errors:
   im = Image.open(filename)
   text = image_to_string(im, cleanup, bool_digits)
  else:
   raise
 finally:
  if cleanup:
   util.perform_cleanup(scratch_image_name, scratch_text_name_root)
 return text

def image_file_to_string ( filename , cleanup = cleanup_scratch_flag , graceful_errors = True , bool_digits = False ) : try : call_tesseract ( filename , scratch_text_name_root , bool_digits ) text = util . retrieve_text ( scratch_text_name_root ) except errors . Tesser_General_Exception : if graceful_errors : im = Image . open ( filename ) text = image_to_string ( im , cleanup , bool_digits ) else : raise finally : if cleanup : util . perform_cleanup ( scratch_image_name , scratch_text_name_root ) return text
applies tesseract to filename; or .