@shelf/aws-lambda-tesseract

    3.0.0 • Public • Published

    aws-lambda-tesseract CircleCI Tesseract

    6 MB Tesseract 4.1 (with English training data) to fit inside AWS Lambda

    Inspired by chrome-aws-lambda & lambda-scanner-ocr

    Install

    $ yarn add @shelf/aws-lambda-tesseract
    

    1.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.

    How does it work?

    This package contains an archive with Tesseract 4.1 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

    See compile-tesseract.sh

    Smoke test that it works by running test.sh script

    See Also

    License

    MIT © Shelf

    Install

    npm i @shelf/aws-lambda-tesseract

    DownloadsWeekly Downloads

    171

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    5.92 MB

    Total Files

    9

    Last publish

    Collaborators

    • vadyanator99
    • nazarko_suv
    • andrii_butsa
    • tarasdyksan
    • hartzler
    • maks.kolesnyk
    • bogdan.kolesnyk
    • gemshelf
    • vladgolubev
    • marianna-milovanova
    • hmelenok
    • knupman
    • maaraanas
    • terret
    • chapelskyi.slavik
    • ahavrysh
    • pihorb
    • irynah
    • diana.kryskuv
    • andy.raven
    • rafler
    • mykola.chepkyi
    • sskalp88
    • demiansua
    • yuriil
    • ktv18
    • dima-bond
    • drews_abuse
    • rostyslav-horytskyi
    • whodeen