n8n-nodes-tesseractjs
v1.1.0
Published
A n8n module that exposes Tesseract.js, an OCR library that can detect text on images
Downloads
228
Readme
n8n-nodes-tesseractjs
This is a n8n community node. It lets you use Tesseract.js in your n8n workflows.
Tesseract is an open source OCR (Optical Character Recognition) engine that can recognize text (machine/typed/printed text, not handwritten) in images (e.g. PNG or JPEG).
n8n is a fair-code licensed workflow automation platform.
Installation
Operations
Compatibility
Usage
Resources
Version history
Installation
Follow the installation guide in the n8n community nodes documentation.
You can quickly get started by importing the sample playbook.
Operations
Extract text
This operation reads the text of the entire image. It outputs a JSON item containing the entire recognized text, and a " confidence value" indicating how likely the generated text is to match the source image, as a percentage:
{
"text": "...",
"confidence": 94
}
Extract boxes
This operation also reads text, but returns more information about the bounding box of each detected block, and the detected language if available.
The "granularity" of the detections can be controlled: you can split on paragraphs, lines, words or individual characters.
{
"blocks": [
{
"text": "This",
"confidence": 95.15690612792969,
"bbox": {
"x0": 36,
"y0": 92,
"x1": 96,
"y1": 116
},
"language": "eng"
},
{
"text": "is",
"confidence": 95.15690612792969,
"bbox": {
"x0": 109,
"y0": 92,
"x1": 129,
"y1": 116
},
"language": "eng"
},
...
]
}
Entire paragraphs:
Per-line statistics:
Compatibility
This node has been tested on n8n v1.68.0, but should also work on older versions. If you encounter an issue with an older version, please raise an issue.
Usage
Input Image Field Name
All Operations of this node have a field Input Image Field Name, where the name of a Binary item should be provided:
The Binary file with that name will be read and processed.
Detect on Entire Image?
It's possible to limit the OCR to a certain segment of an image, by toggling the Detect on Entire Image? switch to Off. When doing so, it's necessary to provide the top and left coordinates of the desired bounding box, and the width and height of the box. For example:
This could delineate a region like this:
When performing OCR on that region, it'd only return the text that was contained in that box, even truncating words of they lie halfway across the bounding box's borders:
Force Resolution
This option can be used if Tesseract can't autodetect the image's resolution, such as a PNG that doesn't carry that information.
Controlling which characters can and can't be recognized
If you know that the source image can only have certain characters (e.g. license plates that can only have uppercase letters, numbers or a dash) or can't have certain characters (e.g. if Tesseract is inserting question marks when there aren't any), you can explicitly specify which characters will be allowed or which characters will be ignored.
For example, when only the digits 0-9 are allowed, and splitting on words:
Or, when disallowing all uppercase characters:
Resources
Version history
v1.0.0
Initial version, contains the Extract text and Extract boxes operations.
v1.0.1
- Fix the installation on N8N instances from NPM
- Add the toggle switch for specifying a bounding box
v1.1.0
- Add the ability to control the Tesseract PSM (block, column, single line, single word, sparse text)
- Add a setting to override the detected DPI of the image
- Add the ability to specify the whitelist and blacklist
Developer info
Releasing changes
- Bump the version in package.json. We use SemVer.
- Add an entry to the top of CHANGELOG.md describing the changes.
- Push changes, open a PR and merge it to master branch (if developing on another branch)
- Create a release. This will kick off the CI which will build and publish the package on NPM