Skip to content

Commit

Permalink
Add Support for ALD Option
Browse files Browse the repository at this point in the history
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.'
  • Loading branch information
ukos-git authored and sbs20 committed Feb 28, 2023
1 parent 436a164 commit 7fdbd95
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/server/src/classes/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '|');
Expand Down Expand Up @@ -97,6 +105,10 @@ module.exports = class Feature {
case '--contrast':
this.asLighting();
break;

case '--ald':
this.asEnum();
break;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/classes/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
3 changes: 3 additions & 0 deletions packages/server/src/classes/scanimage-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/server/src/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ definitions:
dynamicLineart:
type: boolean
example: false
ald:
type: string
example: 'yes'
required:
- deviceId
- resolution
Expand Down

0 comments on commit 7fdbd95

Please sign in to comment.