I have installed tesseract
in C:\Program Files (x86)\Tesseract-OCR
. In command prompt if I am executing with tesseract 123.png sample
, then it works. But I can not use tesseract
with php
. I have tried many libraries and codes for the same.
Someone could help me on this please?
If you needs to use Tesseract in php code, the way to do this is using the http://php.net/manual/en/function.exec.php or http://php.net/manual/en/function.shell-exec.php functions, both allow you to execute bash codes like in "command prompt", but you needs to have more attention to use that, this open several security issues because the client input data sometimes is malicious. Hope it helps!
A working examples:
exec("tesseract C:/your/path/file.png C:/output/file");
Another thing, in part C:/output/file, you don't need to put .txt in output path, tesseract always do the output as .txt file extension.
If the Tesseract is not present on "Environment Variables" the solution is to pass the full executable file path:
shell_exec('"C:/Program Files (x86)/Tesseract-OCR/tesseract.exe" C:/path/to/image C:/output/path/')