From 7fdbd9539d2b14a73617138e4fff4151fc36fa91 Mon Sep 17 00:00:00 2001 From: Matthias Kastner Date: Sun, 19 Feb 2023 21:54:33 +0000 Subject: [PATCH] Add Support for ALD Option Implement Parsing of (yes|no) options and add --ald to the command builder of scanimage. The feature is to turn on scanning when the automatic document feeder detects the start of the page. --ald[=(yes|no)] [no] [advanced]' Scanner detects paper lower edge. May confuse some frontends.' --- packages/server/src/classes/feature.js | 12 ++++++++++++ packages/server/src/classes/request.js | 4 ++++ packages/server/src/classes/scanimage-command.js | 3 +++ packages/server/src/swagger.yml | 3 +++ 4 files changed, 22 insertions(+) diff --git a/packages/server/src/classes/feature.js b/packages/server/src/classes/feature.js index 2e95f792..0939620c 100644 --- a/packages/server/src/classes/feature.js +++ b/packages/server/src/classes/feature.js @@ -36,6 +36,14 @@ module.exports = class Feature { this.interval = steps ? Number(steps[1]) : 1; } + asEnum() { + // Example: [=(yes|no)] + const match = /^\[=\((.*)\)\]$/.exec(this.parameters); + if (match !== null) { + this.options = match[1].split('|'); + } + } + asResolution() { if (this.parameters.indexOf('|') > -1) { this.options = splitNumbers(this.parameters, '|'); @@ -97,6 +105,10 @@ module.exports = class Feature { case '--contrast': this.asLighting(); break; + + case '--ald': + this.asEnum(); + break; } } } diff --git a/packages/server/src/classes/request.js b/packages/server/src/classes/request.js index 2d592538..836eee50 100644 --- a/packages/server/src/classes/request.js +++ b/packages/server/src/classes/request.js @@ -98,6 +98,10 @@ module.exports = class Request { ? data.params.dynamicLineart : true; } + if ('--ald' in features) { + this.params.ald = data.params.ald || features['--ald'].default; + assertContains(features['--ald'].options, this.params.ald, 'Invalid --ald'); + } log.trace(LogFormatter.format().full(this)); } diff --git a/packages/server/src/classes/scanimage-command.js b/packages/server/src/classes/scanimage-command.js index 2d9515a0..353d1af6 100644 --- a/packages/server/src/classes/scanimage-command.js +++ b/packages/server/src/classes/scanimage-command.js @@ -108,6 +108,9 @@ module.exports = class ScanimageCommand { cmdBuilder.arg('--format', params.format); + if ('ald' in params) { + cmdBuilder.arg(`--ald=${params.ald}`); + } if ('depth' in params) { cmdBuilder.arg('--depth', params.depth); } diff --git a/packages/server/src/swagger.yml b/packages/server/src/swagger.yml index b78d67c4..79d67614 100644 --- a/packages/server/src/swagger.yml +++ b/packages/server/src/swagger.yml @@ -572,6 +572,9 @@ definitions: dynamicLineart: type: boolean example: false + ald: + type: string + example: 'yes' required: - deviceId - resolution