2

I installed tesseract v3.01 on windows 7. I added tesseract path to the environments variables. I obtains the right output after typing this command in the cmd windows: "tesseract test.tif test".

When I try to get the same result in php using the folowing script, I get an empty array and no file is generated:

<?php

try {
    exec("tesseract.exe test.tif test", $msg);
    var_export($msg);
} catch (Exception $e) {
    echo $e;
}

?>

Any clue ?

thanks in advance !

2 Answers 2

0
<?php

try {
    $msg = array(); // TRY THIS 
    exec("tesseract.exe test.tif test", $msg);
    var_export($msg);
} catch (Exception $e) {
    echo $e;
}

?>
Sign up to request clarification or add additional context in comments.

3 Comments

I still have the same empty array as a result :(
So I tested again... after copying the tesseract files into the php script' folder It was working well. I tried to use putenv(). Tesseract is declared in the path environment variable...
Ok, it is because of permissions, perhaps. Try this exec("tesseract.exe test.tif test 2>&1", $msg);
0

Why not try specifying the full path to tesseract?

Not sure how to do this on windows, but on mac terminal, I type in which tesseract and it will find the full path of tesseract. You can then enter that full path, in my case /usr/local/bin/tesseract into the exec command.

try {
    $msg = array();
    exec("/usr/local/bin/tesseract test.tif test", $msg);
    var_export($msg);
} catch (Exception $e) {
    echo $e;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.