diff --git a/examples/file-input/demo.html b/examples/file-input/demo.html index 55a95e9..e6beb3c 100644 --- a/examples/file-input/demo.html +++ b/examples/file-input/demo.html @@ -127,7 +127,7 @@ function recognizeFile(file){ - +
diff --git a/package-lock.json b/package-lock.json index baa5b3d..28ba051 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2152,14 +2152,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2174,20 +2172,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2304,8 +2299,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2317,7 +2311,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2332,7 +2325,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2340,14 +2332,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2366,7 +2356,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2447,8 +2436,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2460,7 +2448,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2582,7 +2569,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5166,11 +5152,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" - }, - "whatwg-fetch": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" } } }, @@ -6287,6 +6268,11 @@ } } }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/src/common/worker.js b/src/common/worker.js index 2e2b495..ae97a03 100644 --- a/src/common/worker.js +++ b/src/common/worker.js @@ -35,9 +35,15 @@ const handleInit = (req, res) => { }; const setImage = (image) => { - const { w, h, data } = readImage(Module, Array.from(image)); - - base.SetImage(data); + const { + w, h, bytesPerPixel, data, pix, + } = readImage(Module, Array.from(image)); + + if (data === null) { + base.SetImage(pix); + } else { + base.SetImage(data, w, h, bytesPerPixel, w * bytesPerPixel); + } base.SetRectangle(0, 0, w, h); return data; }; @@ -48,7 +54,6 @@ const loadLanguage = (req, res, cb) => { langs: lang, tessModule: Module, langURI: langPath, - cache: true, }).then(cb); }; diff --git a/tests/assets/testocr.bmp b/tests/assets/testocr.bmp new file mode 100755 index 0000000..b22531f Binary files /dev/null and b/tests/assets/testocr.bmp differ