Closed Refl0w closed 3 years ago
After some frustrations, found a workaround. It has to do with the windows TEMP directory, tried giving the TEMP folder on C all rights which are needed, even temporally all rights to everyone and guests without success.
Found the addition to the command to assign a temp folder on another place, just for this project, which is now in the root of this project, which seems to work.
->tempDir('ocr/tmp')
Something isn't working well for this project to use the windows temp directory. Hope you can still have a look at it, would prefer to use windows original temp folder, instead of using another one just for this project. At least I can continue developing ;)
Hi, nice workaround, but can you check if the temp dir is setup in php.ini?
Usually that should point to c:\youruser\appdata\local\temp
You may type echo %temp% in cmd, PowerShell or Windows terminal.
BR George
@Refl0w tempDir()
option was created exactly for this kind of scenario, where permissions of system temp dirs are restrictive. So you made the right call, it is not a workaround at all.
But if you really feel strongly about it, please share more details about your env, as @gxgl suggested.
(even though there is nothing wrong with the lib per se, I'll keep this issue open for now, as I investigate other alternatives)
apparently, I already addressed this issue ... but I expected you to see a different exception: https://github.com/thiagoalessio/tesseract-ocr-for-php/blob/82cfd7879d6158be3098714f1d5c860f344a0e29/src/FriendlyErrors.php#L111
something like:
PHP Fatal error: Uncaught thiagoalessio\TesseractOCR\NoWritePermissionsForOutputFile: Error! No permission to write to $path
Make sure you have the right outputFile and permissions to write to the folder
also noticed that you are using tesseract 5 alpha ... i haven't tested this version yet. so I guess I'll close this issue for now and revisit it if needed when I add tess 5 support.
Getting the following PHP error:
[25-Nov-2020 22:41:47 Europe/Amsterdam] PHP Fatal error: Uncaught thiagoalessio\TesseractOCR\UnsuccessfulCommandException: Error! The command did not produce any output.
Generated command: "tesseract" "text.png" "C:\Windows\TEMP\ocr3984.tmp"
Returned message: Tesseract Open Source OCR Engine v5.0.0-alpha.20200328 with Leptonica in D:\website\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php:74 Stack trace:
0 D:\website\vendor\thiagoalessio\tesseract_ocr\src\TesseractOCR.php(39): thiagoalessio\TesseractOCR\FriendlyErrors::checkCommandExecution(Object(thiagoalessio\TesseractOCR\Command), '', 'Tesseract Open ...')
1 D:\website\ocr.php(5): thiagoalessio\TesseractOCR\TesseractOCR->run()
2 {main}
thrown in D:\website\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 74
Using this command:
<?php require_once 'vendor/autoload.php'; use thiagoalessio\TesseractOCR\TesseractOCR; echo (new TesseractOCR('text.png')) ->run(); ?>
This code works on my localhost webserver, but not on my real server.