From b1c30dfad9a89be769660c17c0da7a1a9356d005 Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Wed, 28 Nov 2018 08:28:03 +0800 Subject: [PATCH] Update examples --- examples/{file-input => browser}/basic.html | 0 examples/{file-input => browser}/demo.html | 0 examples/file-input/README.md | 1 - examples/node/basic.js | 18 ---------------- examples/node/detect.js | 7 +++++-- examples/node/recognize.js | 23 +++++++++++++++++++++ 6 files changed, 28 insertions(+), 21 deletions(-) rename examples/{file-input => browser}/basic.html (100%) rename examples/{file-input => browser}/demo.html (100%) delete mode 100644 examples/file-input/README.md delete mode 100644 examples/node/basic.js mode change 100644 => 100755 examples/node/detect.js create mode 100755 examples/node/recognize.js diff --git a/examples/file-input/basic.html b/examples/browser/basic.html similarity index 100% rename from examples/file-input/basic.html rename to examples/browser/basic.html diff --git a/examples/file-input/demo.html b/examples/browser/demo.html similarity index 100% rename from examples/file-input/demo.html rename to examples/browser/demo.html diff --git a/examples/file-input/README.md b/examples/file-input/README.md deleted file mode 100644 index 4e768b5..0000000 --- a/examples/file-input/README.md +++ /dev/null @@ -1 +0,0 @@ -# \ No newline at end of file diff --git a/examples/node/basic.js b/examples/node/basic.js deleted file mode 100644 index 515bdb1..0000000 --- a/examples/node/basic.js +++ /dev/null @@ -1,18 +0,0 @@ -// replace this with require('tesseract.js') -const path = require('path'); -const { TesseractWorker } = require('../../'); - -const image = path.resolve(__dirname, '../../tests/assets/images/cosmic.png'); -const tessWorker = new TesseractWorker(); - -tessWorker.recognize(image) - .then((data) => { - console.log('then\n', data.text); - }) - .catch((err) => { - console.log('catch\n', err); - }) - .finally(() => { - console.log('finally\n'); - process.exit(); - }); diff --git a/examples/node/detect.js b/examples/node/detect.js old mode 100644 new mode 100755 index c85bbd2..20e20a1 --- a/examples/node/detect.js +++ b/examples/node/detect.js @@ -1,10 +1,13 @@ -// replace this with require('tesseract.js') +#!/usr/bin/env node const path = require('path'); const { TesseractWorker } = require('../../'); -const image = path.resolve(__dirname, '../../tests/assets/images/cosmic.png'); +const [,, imagePath] = process.argv; +const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png')); const tessWorker = new TesseractWorker(); +console.log(`Detecting ${image}`); + tessWorker.detect(image) .progress((info) => { console.log(info); diff --git a/examples/node/recognize.js b/examples/node/recognize.js new file mode 100755 index 0000000..d283944 --- /dev/null +++ b/examples/node/recognize.js @@ -0,0 +1,23 @@ +#!/usr/bin/env node +const path = require('path'); +const { TesseractWorker } = require('../../'); + +const [,, imagePath] = process.argv; +const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png')); +const tessWorker = new TesseractWorker(); + +console.log(`Recognizing ${image}`); + +tessWorker.recognize(image) + .progress((info) => { + console.log(info); + }) + .then((data) => { + console.log(data.text); + }) + .catch((err) => { + console.log('Error\n', err); + }) + .finally(() => { + process.exit(); + });