shelfio / aws-lambda-tesseract Goto Github PK
View Code? Open in Web Editor NEW6 MB Tesseract (with English training data) to fit inside AWS Lambda
License: MIT License
6 MB Tesseract (with English training data) to fit inside AWS Lambda
License: MIT License
I'm very inexperienced with Lambda functions so apologies if this is a basic error.
I have a very simple Node app with the following structure:
index.js
tmp/demo.png
I added the demo code into index.js:
const { getTextFromImage, isSupportedFile } = require('@shelf/aws-lambda-tesseract');
exports.handler = async event => {
console.log("Running...");
const imagePath = "/tmp/demo.png";
if(isSupportedFile(imagePath)) {
console.log(`${imagePath} is supported`)
} else {
return false;
}
return getTextFromImage(imagePath);
};
However, when I run the Lambda it errors:
Response:
{
"errorType": "Error",
"errorMessage": "Command failed: /tmp/tesseract-standalone/tesseract /tmp/demo.png stdout -l eng\nError, cannot read input file /tmp/demo.png: No such file or directory\nError during processing.\n",
"trace": [
"Error: Command failed: /tmp/tesseract-standalone/tesseract /tmp/demo.png stdout -l eng",
"Error, cannot read input file /tmp/demo.png: No such file or directory",
"Error during processing.",
"",
" at checkExecSyncError (child_process.js:630:11)",
" at execFileSync (child_process.js:648:15)",
" at module.exports.getTextFromImage (/opt/nodejs/node_modules/@shelf/aws-lambda-tesseract/src/index.js:19:18)"
]
}
Why can't the Lambda find the image in my tmp
folder?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.circleci/config.yml
node 5.1.0
aws-cli 3.1.4
package.json
is-image 3.1.0
tar 6.1.13
@babel/cli 7.20.7
@babel/core 7.20.12
@babel/preset-env 7.20.2
@babel/preset-typescript 7.18.6
@shelf/babel-config 1.2.0
@shelf/eslint-config 2.27.1
@shelf/prettier-config 1.0.0
@types/jest 29.4.0
@types/tar 6.1.3
eslint 8.33.0
husky 8.0.3
jest 29.4.1
lint-staged 13.1.0
prettier 2.8.3
typescript 4.9.4
node >=16
Hi forks,
Thanks for a very useful library :)
I think it will be a big improvement if we support sending tesseract parameters such as:
getTextFromImage(image, {
tessedit_char_whitelist: "123456789" // number only
})
What do you think?
Hi, can you add the option for output types please? Could look something like this:
`async function getTextFromImage(filePath, outputType) {
await (0, _tar.extract)({
file: inputPath,
cwd: '/tmp'
});
if (outputType !== 'stdout' || outputType !== 'txt' || outputType !== 'pdf'|| outputType !== 'hocr'|| outputType !== 'tsv') {
return "BAD_OUTPUT_TYPE"
}
const stdout = (0, _child_process.execFileSync)(outputPath, [filePath, outputType, '-l', 'eng'], {
cwd: '/tmp/tesseract-standalone',
env: {
LD_LIBRARY_PATH: './lib',
TESSDATA_PREFIX: './tessdata'
}
});
(0, _child_process.execSync)(rm ${filePath}
);
return stdout.toString();
}`
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: Cannot find preset's package (github>shelfio/renovate-config)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.