Skip to content

tesseract: [FIX] pdf pre-processing#468

Merged
bosd merged 1 commit intoinvoice-x:masterfrom
bosd:fix-tesseract-stream
Feb 11, 2023
Merged

tesseract: [FIX] pdf pre-processing#468
bosd merged 1 commit intoinvoice-x:masterfrom
bosd:fix-tesseract-stream

Conversation

@bosd
Copy link
Copy Markdown
Collaborator

@bosd bosd commented Feb 10, 2023

Before this PR the mimetype of the input file was detected by it's extension.
It works fine for cli usage.

It fails when invoice2data is used as a library and a tempfile/stream is used as an input. (as there is no extension available)
Making it impossible to parse pdf files when using invoice2data as a library.
As tesseract cannot handle pdf files as an input.

After this pr, the mimetype is also detected when using invoice2data as a library.

@m3nu , @rmilecki I'm consideirng this as a hotfix, so fasttracking this one.

detect the mimetype of the input, also when using invoice2data as a library
@bosd bosd added priority:high priority high type:bug Something isn't working labels Feb 10, 2023
@bosd bosd merged commit 26aa28a into invoice-x:master Feb 11, 2023
@bosd bosd deleted the fix-tesseract-stream branch February 11, 2023 07:31
@rmilecki
Copy link
Copy Markdown
Collaborator

Thanks for handling this.

@bosd
Copy link
Copy Markdown
Collaborator Author

bosd commented Feb 18, 2023

It turns out, this really did not make a difference. The guess_type function also looks at the file extension.
Instead of running low level compares on the content.

It turned out that the problem was in the program calling invoice2data.
It was passing a tempfile without extension.
Forcing the program to always pass the .pdf extension fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high priority high type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants