Skip to content

Commit 031c1c6

Browse files
committed
Release v1.2.0
1 parent 027a530 commit 031c1c6

4 files changed

Lines changed: 31 additions & 21 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,15 @@ Initial version, contains the **Extract text** and **Extract boxes** operations.
160160
* Add a setting to override the detected DPI of the image
161161
* Add the ability to specify the whitelist and blacklist
162162

163+
### v1.2.0
164+
165+
* Update the Tesseract.JS version to v6.0.0. No user-facing changes. Please [report any issues that you find](https://github.com/jreyesr/n8n-nodes-tesseractjs/issues)!
166+
163167
## Developer info
164168

165169
### Releasing changes
166170

167171
1. Bump the version in package.json. We use SemVer.
168-
2. Add an entry to the top of CHANGELOG.md describing the changes.
172+
2. Add an entry on the [Version History](#version-history) section above describing the changes.
169173
3. Push changes, open a PR and merge it to master branch (if developing on another branch)
170174
4. Create a release. This will kick off the CI which will build and publish the package on NPM

nodes/TesseractNode/operations.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {IExecuteFunctions, INodeExecutionData} from "n8n-workflow";
2-
import type {Worker} from "tesseract.js";
2+
import type {Worker, Block} from "tesseract.js";
33

44
type BoundingBox = {
55
top: number, left: number,
@@ -28,10 +28,22 @@ export async function extractBoxes(this: IExecuteFunctions, worker: Worker, item
2828
};
2929

3030
const data = await this.helpers.getBinaryDataBuffer(itemIndex, imageFieldName)
31-
const d = await worker.recognize(data, {rectangle: bbox});
31+
const d = await worker.recognize(data, {rectangle: bbox}, {blocks: true});
32+
33+
// NOTE: since v1.2.0, we start clobbering the nice TS object here, to restore it to the pre-v6 API, which included additional properties
34+
// See https://github.com/naptha/tesseract.js/issues/993#issuecomment-2597678687
35+
// @ts-ignore
36+
d.data.paragraphs = d.data.blocks!.map((block) => block.paragraphs).flat();
37+
// @ts-ignore
38+
d.data.lines = d.data.blocks!.map((block) => block.paragraphs.map((paragraph) => paragraph.lines)).flat(2);
39+
// @ts-ignore
40+
d.data.words = d.data.blocks!.map((block) => block.paragraphs.map((paragraph) => paragraph.lines.map((line) => line.words))).flat(3);
41+
// @ts-ignore
42+
d.data.symbols = d.data.blocks!.map((block) => block.paragraphs.map((paragraph) => paragraph.lines.map((line) => line.words.map((word) => word.symbols)))).flat(4);
3243

3344
newItem.json = {
34-
blocks: d.data[granularity].map(b => ({
45+
// @ts-ignore
46+
blocks: d.data[granularity].map((b: Block) => ({
3547
text: b.text,
3648
confidence: b.confidence,
3749
bbox: b.bbox,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "n8n-nodes-tesseractjs",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "A n8n module that exposes Tesseract.js, an OCR library that can detect text on images",
55
"keywords": [
66
"n8n-community-node-package"
@@ -53,6 +53,6 @@
5353
"n8n-workflow": "*"
5454
},
5555
"dependencies": {
56-
"tesseract.js": "^5.1.1"
56+
"tesseract.js": "^6.0.0"
5757
}
5858
}

pnpm-lock.yaml

Lines changed: 9 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)