From 5b0504e5f341e60851f0751e19ccd35622110ecf Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 7 Jun 2016 17:56:54 +1000 Subject: [PATCH 1/2] Add feature selection (hocr/tsv) --- lib/tesseract.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tesseract.js b/lib/tesseract.js index db9729a..9d98ed9 100644 --- a/lib/tesseract.js +++ b/lib/tesseract.js @@ -23,7 +23,8 @@ var Tesseract = { 'l': 'eng', 'psm': 3, 'config': null, - 'binary': 'tesseract' + 'binary': 'tesseract', + 'format': null }, /** @@ -69,6 +70,11 @@ var Tesseract = { command.push(options.config); } + var validFormats = ['hocr', 'tsv']; + if (options.format !== null && validFormats.indexOf(options.format) > -1) { + command.push(options.format); + } + command = command.join(' '); var opts = options.env || {}; From 2800692525560d836de95a19ed92ba9a38a3f181 Mon Sep 17 00:00:00 2001 From: Geoffrey Roberts Date: Tue, 7 Jun 2016 18:02:15 +1000 Subject: [PATCH 2/2] Normalise format --- lib/tesseract.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tesseract.js b/lib/tesseract.js index 9d98ed9..9520f20 100644 --- a/lib/tesseract.js +++ b/lib/tesseract.js @@ -71,8 +71,8 @@ var Tesseract = { } var validFormats = ['hocr', 'tsv']; - if (options.format !== null && validFormats.indexOf(options.format) > -1) { - command.push(options.format); + if (options.format !== null && validFormats.indexOf(options.format.toLowerCase()) > -1) { + command.push(options.format.toLowerCase()); } command = command.join(' ');