Forums

Tesseract throws an error "Tesseract Open Source OCR Engine v4.1.1 with Leptonica Error in findFileFormatStream: truncated file Error during processin g."

Good evening!

I can't find a way to get rid of the following error when running an app with tesseract: <pre> File "/home/happypufin/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 430, in image_to_string return { File "/home/happypufin/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 433, in <lambda> Output.STRING: lambda: run_and_get_output(args), File "/home/happypufin/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 295, in run_and_get_output run_tesseract(*kwargs) File "/home/happypufin/.local/lib/python3.10/site-packages/pytesseract/pytesseract.py", line 271, in run_tesseract raise TesseractError(proc.returncode, get_errors(error_string)) pytesseract.pytesseract.TesseractError: (1, 'Tesseract Open Source OCR Engine v4.1.1 with Leptonica Error in findFileFormatStream: truncated file Error during processin g.') </pre>

I printed out the arguments that are passed to tesseract: ['/usr/bin/tesseract', '/home/happypufin/text_splitter_bot/tmp.jpeg', '/tmp/tess_0jr1oi8k', '-l', 'eng']

And the command <pre>$ /usr/bin/tesseract /home/happypufin/text_splitter_bot/tmp.jpeg /tmp/tess_0jr1oi8k -l eng Tesseract Open Source OCR Engine v4.1.1 with Leptonica </pre> works just fine

But it doesn't work when I run it from code...

And the code works in tesseract 5.3.0 when I run it locally

Could you please help in any way?

If you're using a file that is transferred from your local machine, make sure it contains what you expect and also check that the file formats between the different versions are compatible.

It is impossible to install tesseract of earlier than the latest version on mac (tried brew install tesseract@4.1.1 with no success) so can't test whether my code will work with tesseract of version 4.1.1.

Probably version 4.1.1 is too old, it is very sad because you provide the best service...

Thanks anyway!