diff --git a/package-lock.json b/package-lock.json index e7eb8f88e..acafea689 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "pino": "^8.15.1", "redoc": "^2.1.2", "secure-json-parse": "^2.7.0", - "tesseract.js": "^4.1.2", + "tesseract.js": "^5.0.0", "upath": "^2.0.1", "word-extractor": "^1.0.4" }, @@ -11407,9 +11407,9 @@ } }, "node_modules/tesseract.js": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tesseract.js/-/tesseract.js-4.1.2.tgz", - "integrity": "sha512-riCr/rbwt0siIf/HiC0W2J/6ndbEcRWVZvwTxeDRPgMwP4douBLYq7i4NgMigWAmJea7GA0r3XGLa2GknRYmPA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tesseract.js/-/tesseract.js-5.0.0.tgz", + "integrity": "sha512-dveto1IstLTEVYSquddE/2iZgtVUElgmRzxwZ67ALZRCpgw0AHRCQ7GIVooNJygbUFDP1QOsBRO5r2c1eQwquw==", "hasInstallScript": true, "dependencies": { "bmp-js": "^0.1.0", @@ -11419,15 +11419,15 @@ "node-fetch": "^2.6.9", "opencollective-postinstall": "^2.0.3", "regenerator-runtime": "^0.13.3", - "tesseract.js-core": "^4.0.4", + "tesseract.js-core": "^5.0.0", "wasm-feature-detect": "^1.2.11", "zlibjs": "^0.3.1" } }, "node_modules/tesseract.js-core": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/tesseract.js-core/-/tesseract.js-core-4.0.4.tgz", - "integrity": "sha512-MJ+vtktjAaT0681uPl6TDUPhbRbpD/S9emko5rtorgHRZpQo7R3BG7h+3pVHgn1KjfNf1bvnx4B7KxEK8YKqpg==" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tesseract.js-core/-/tesseract.js-core-5.0.0.tgz", + "integrity": "sha512-lJur5LzjinW5VYMKlVNnBU2JPLpO+A9VqAYBeuV+ZgH0hKvsnm+536Yyp+/zRTBdLe7D6Kok0FN9g+TE4J8qGA==" }, "node_modules/tesseract.js/node_modules/regenerator-runtime": { "version": "0.13.11", diff --git a/package.json b/package.json index 858422ee3..7db05d2d2 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "pino": "^8.15.1", "redoc": "^2.1.2", "secure-json-parse": "^2.7.0", - "tesseract.js": "^4.1.2", + "tesseract.js": "^5.0.0", "upath": "^2.0.1", "word-extractor": "^1.0.4" } diff --git a/src/plugins/image-to-txt/index.js b/src/plugins/image-to-txt/index.js index f87c2229b..6972661bc 100644 --- a/src/plugins/image-to-txt/index.js +++ b/src/plugins/image-to-txt/index.js @@ -31,7 +31,7 @@ async function plugin(server, options) { cachePath: joinSafe(__dirname, "../../.."), corePath: joinSafe( __dirname, - "../../../node_modules/tesseract.js-core/tesseract-core.wasm.js" + "../../../node_modules/tesseract.js-core" ), langPath: joinSafe(__dirname, "../../../ocr_lang_data"), workerPath: joinSafe( @@ -54,9 +54,11 @@ async function plugin(server, options) { Array(options.workers) .fill(0) .map(async () => { - const worker = await createWorker(workerConfig); - await worker.loadLanguage(options.languages); - await worker.initialize(options.languages); + const worker = await createWorker( + options.languages, + 1, + workerConfig + ); await worker.setParameters(workerParams); return scheduler.addWorker(worker); })