File size: 444 Bytes
0347dd6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const Tesseract = require('tesseract.js');
const fs = require('fs');
const image = process.argv[2];
const lang = process.argv[3];
const saveFilePath = process.argv[4];
Tesseract.recognize(
image,
lang,
{
logger: m => console.log(m)
}
).then(({ data: { text } }) => {
console.log(text);
fs.writeFileSync(saveFilePath, text);
}).catch(err => {
console.error(err);
fs.writeFileSync(saveFilePath, 'Error: ' + err.message);
}); |