npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

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"
		},
		...
	]
}

an image of some text with Tesseract detections overlaid. Each word is surrounded in a light red box, and each box also has text on top indicating the detected word and confidence percentage

Entire paragraphs:

an image of the same text with Tesseract per-paragraph detections overlaid as one red box covering each paragraph

Per-line statistics:

an image of the same text with Tesseract per-line detections overlaid as one red box covering each line

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:

a screenshot of the node UI showing an input item with Binary data

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:

a screenshot of the node settings showing that when the Detect on Entire Image switch is Off, there are fields to provide the top, left, width and height of the desired bounding box

This could delineate a region like this:

an image with some text and a light green box that covers only part of it

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:

an image with some text and the OCR detections overlaid, showing that only text that lies inside the area of interest has been recognized

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:

a screenshot of text where only a number 12 has been detected. All other characters, which are letters, are ignored

Or, when disallowing all uppercase characters:

a screenshot of text where the capital letters that start each sentence have been ignored

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

  1. Bump the version in package.json. We use SemVer.
  2. Add an entry to the top of CHANGELOG.md describing the changes.
  3. Push changes, open a PR and merge it to master branch (if developing on another branch)
  4. Create a release. This will kick off the CI which will build and publish the package on NPM