From 8bc01714025b1f76f42fb2b6a84abf2101a82641 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 23 Sep 2019 14:36:09 +0100 Subject: [PATCH] Dynamic Lineart --- classes/Api.js | 6 ++++-- classes/Device.js | 4 +--- classes/ScanRequest.js | 6 +----- classes/Scanimage.js | 6 ++---- index.html | 17 +++++++---------- src/client.js | 43 ++++++++++++++---------------------------- 6 files changed, 29 insertions(+), 53 deletions(-) diff --git a/classes/Api.js b/classes/Api.js index 0a6cbccb..8484a9b4 100755 --- a/classes/Api.js +++ b/classes/Api.js @@ -50,7 +50,9 @@ module.exports = function () { return convert.execute() .then(function () { var fileInfo = new FileInfo(options.target); - if (!fileInfo.exists()) throw new Error("File does not exist"); + if (!fileInfo.exists()) { + throw new Error("File does not exist"); + } return fileInfo; }); }; @@ -67,7 +69,7 @@ module.exports = function () { mode: req.mode, brightness: req.brightness, contrast: req.contrast, - disableDynamicLineart: req.disableDynamicLineart, + dynamicLineart: req.dynamicLineart, outputFilepath: Config.PreviewDirectory + 'preview.tif', resolution: Config.PreviewResolution }); diff --git a/classes/Device.js b/classes/Device.js index 5f68090c..ba9b92eb 100644 --- a/classes/Device.js +++ b/classes/Device.js @@ -86,9 +86,7 @@ module.exports = function () { }; _this.isFeatureSupported = function (feature) { - if (_this.data && - _this.data.features && - feature in _this.data.features) { + if (_this.data && _this.data.features && feature in _this.data.features) { return _this.data.features[feature].default !== 'inactive'; } diff --git a/classes/ScanRequest.js b/classes/ScanRequest.js index a3fa8abe..420cb92a 100644 --- a/classes/ScanRequest.js +++ b/classes/ScanRequest.js @@ -55,10 +55,6 @@ var ScanRequest = function (def) { errors.push('Invalid format type'); } - if (_this.disableDynamicLineart && !device.isFeatureSupported('--disable-dynamic-lineart')) { - errors.push('disableDynamicLineart set to true, but unsupported by device'); - } - return errors; }; }; @@ -75,7 +71,7 @@ ScanRequest.default = { brightness: 0, contrast: 0, convertFormat: 'tif', - disableDynamicLineart: false + dynamicLineart: true }; module.exports = ScanRequest; \ No newline at end of file diff --git a/classes/Scanimage.js b/classes/Scanimage.js index 557fc9f6..834cb783 100755 --- a/classes/Scanimage.js +++ b/classes/Scanimage.js @@ -36,7 +36,8 @@ module.exports = function () { cmd += ' --contrast ' + scanRequest.contrast; } - if (scanRequest.mode === 'Lineart' && scanRequest.disableDynamicLineart) { + if (scanRequest.mode === 'Lineart' && !scanRequest.dynamicLineart && + device.isFeatureSupported('--disable-dynamic-lineart')) { cmd += ' --disable-dynamic-lineart=yes '; } @@ -50,7 +51,6 @@ module.exports = function () { }; _this.execute = function (scanRequest) { - if (!exists()) { return Q.reject(new Error('Unable to find Scanimage at "' + Config.Scanimage + '"')); } @@ -70,11 +70,9 @@ module.exports = function () { }; System.trace('Scanimage.execute:start'); - response.errors = scanRequest.validate(device); if (response.errors.length === 0) { - response.cmdline = commandLine(scanRequest, device); return System.execute(response.cmdline) diff --git a/index.html b/index.html index 15eef25e..d32e5032 100644 --- a/index.html +++ b/index.html @@ -19,11 +19,8 @@