run([ $bin, $imagePath, 'stdout', '-l', 'eng', '--oem', (string) $oem, '--psm', (string) $psm, ]); if (! $result->successful()) { Log::channel('stack')->warning('tesseract ocr failed', [ 'path' => $imagePath, 'error' => mb_substr($result->errorOutput() ?: $result->output(), 0, 500), ]); return ''; } return trim($result->output()); } }