removed old logic
This commit is contained in:
@@ -38,17 +38,17 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
|||||||
return response()->json(['success' => false, 'error' => 'File not found']);
|
return response()->json(['success' => false, 'error' => 'File not found']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = null;
|
try {
|
||||||
$return_var = null;
|
// $text = (new TesseractOCR($filePath))->lang('eng')->run();
|
||||||
|
$text = (new TesseractOCR($filePath))
|
||||||
|
->executable('/usr/bin/tesseract')
|
||||||
|
->env(['PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'])
|
||||||
|
->lang('eng')
|
||||||
|
->run();
|
||||||
|
|
||||||
// Call tesseract directly, capture stderr with 2>&1
|
|
||||||
exec("/usr/bin/tesseract " . escapeshellarg($filePath) . " stdout -l eng 2>&1", $output, $return_var);
|
|
||||||
|
|
||||||
if ($return_var === 0) {
|
|
||||||
$text = implode("\n", $output);
|
|
||||||
return response()->json(['success' => true, 'text' => $text]);
|
return response()->json(['success' => true, 'text' => $text]);
|
||||||
} else {
|
} catch (\Exception $e) {
|
||||||
return response()->json(['success' => false, 'error' => implode("\n", $output)]);
|
return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user