Package Exports
- @shelf/aws-lambda-tesseract
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@shelf/aws-lambda-tesseract) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
aws-lambda-tesseract 
11 MB Tesseract (with English training data) to fit inside AWS Lambda compressed with Brotli
Inspired by chrome-aws-lambda & lambda-scanner-ocr
Install
$ yarn add aws-lambda-tesseractHow does it work?
This package contains an archive with Tesseract 4.0 beta compiled for usage in AWS Lambda environment.
When Lambda starts, it unpacks an archive with a binary to the /tmp folder and makes sure it's done only once per Lambda cold start.
You can import a path to the Tesseract binary and spawn a child process to do the OCR magic ✨
Usage
const {getExecutablePath} = require('aws-lambda-tesseract');
const {execSync} = require('child_process');
const ttBinary = await getExecutablePath();
module.exports.handler = (event) => {
// assuming there is a photo.jpg inside /tmp dir
const stdout = execSync(`${ttBinary} /tmp/photo.jpg ${defaultArgs.join(' ')}`);
execSync(`rm /tmp/photo.jpg`);
return stdout.toString();
}See Also
License
MIT © Shelf