Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
ocr-bulk
Advanced tools
Changelog
0.6.0
node-tesseract
which supports PDF outputReadme
Perform OCR recognition on multiple images.
Note that this doesn't currently contain a normal functioning binary and needs adapting of source.
npm i -D ocr-bulk
(for development use) or npm i -P ocr-bulk
(for production use)For PDF conversion support:
brew install ghostscript
'use strict';
const {join} = require('path');
const ot = require('ocr-bulk');
(async () => {
await ot.writeFile({
start: 1,
end: 3,
outputPath: join(__dirname, 'ocr.txt'),
getImagePath (i) {
return `C:\\Users\\Brett\\Documents\\images\\image-${ot.pad(i, 4)}.jpg`;
},
concatenater (text, i) {
// eslint-disable-next-line no-console
console.log('Finishing ' + i);
return `\n\n{{page|${i}}}\n\n${text}`;
}
});
// eslint-disable-next-line no-console
console.log('Saved!');
})();
writeFile({start: ..., end: ..., getImagePath: cb(i), readErrback: cb(err), outputPath: ..., concatenater: cb(text, i), tesseractOptions: {}, done: cb()})
- This method will concatenate results based on the supplied arguments and output into a single file. Passed a single config object whose start
property indicates a number at which to begin reading images (defaults to 1
) and end
is a required ending number. getImagePath
is a required callback which is passed the current iteration number and should be used to return an image path. readErrback
is an optional errback which will be passed the file read error if one occurs. outputPath
is a required string indicating the desired path to which to write the concatenated contents. concatenater
is a callback which will be called with the OCR'd text and the current iteration count. It should return the value to be appended to any previously concatenated values (starting with an empty string). done
is an optional callback which will be called upon completion of appending OCR for all read files (those between the supplied start and end points); the Promise
returned from writeFile
can be used for the same purpose.readOCR({start: ..., end: ..., getImagePath: cb(i), readErrback: cb(err), processor: cb(text, i), tesseractOptions: {}, done: cb()})
- Passed a single config object whose start
property indicates a number at which to begin reading images (defaults to 1
) and end
is a required ending number. getImagePath
is a required callback which is passed the current iteration number and should be used to return an image path. readErrback
is an optional errback which will be passed the file read error if one occurs. processor
is a required callback argument which receives the current OCR'd text and the current iteration number as arguments. done
is an optional callback which will be called upon completion of reading all files between the supplied start and end points; the Promise
returned from writeFile
can be used for the same purpose.pad(val, len, chr)
- A utility intended for use by getImagePath
to add padding in retrieval of predictable image path inputs. The required val
is the value to be padded, the required len
indicates the desired total length including padding, and chr
is an optional character to be used for padding (defaults to "0").FAQs
Perform OCR recognition on multiple images
The npm package ocr-bulk receives a total of 16 weekly downloads. As such, ocr-bulk popularity was classified as not popular.
We found that ocr-bulk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.