Package Exports
- @shelf/aws-lambda-tesseract
- @shelf/aws-lambda-tesseract/lib/index.js
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

6 MB Tesseract 5.3.3 (with English training data) to fit inside AWS Lambda
Inspired by chrome-aws-lambda & lambda-scanner-ocr
Install
$ yarn add @shelf/aws-lambda-tesseract1.x versions of this library were compiled for Node 8.10.
2.x was compiled for Node 10.x runtime.
3.x works for Node 12.x runtime.
4.x works for Node 16.x runtime and compiled with Tesseract 5.1.0. It works with x86_64 CPUs for now only.
5.x works for Node 18.x runtime and compiled with Tesseract 5.3.3. It works with arm64 CPUs.
How does it work?
This package contains an archive with Tesseract 5.3.3 compiled for usage in AWS Lambda environment.
When a 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.
Usage
const {getTextFromImage, isSupportedFile} = require('@shelf/aws-lambda-tesseract');
module.exports.handler = async event => {
// assuming there is a photo.jpg inside /tmp dir
// original file will be deleted afterwards
if (!isSupportedFile('/tmp/photo.jpg')) {
return false;
}
return getTextFromImage('/tmp/photo.jpg');
};isSupportedFile checks that file has image-like file extension and it's not in the list of
unsupported by Tesseract file extensions.
Compile It Yourself
Smoke test that it works by running test.sh script
See Also
Publish
$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tagsLicense
MIT © Shelf