Skip to content

Commit

Permalink
Merge pull request #190 from sbs20/development
Browse files Browse the repository at this point in the history
Scan geometry, documentation and filter translation
  • Loading branch information
sbs20 authored Apr 13, 2021
2 parents 6a47fa6 + 0f2f91e commit 938a9b0
Show file tree
Hide file tree
Showing 21 changed files with 156 additions and 99 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ more scanners (using SANE) on a network without the need for drivers or
complicated installation.

### Features

* Cropping
* Source selection (Flatbed / ADF)
* Resolution
Expand All @@ -39,6 +40,7 @@ It supports any
Copyright 2016-2021 [Sam Strachan](https://github.com/sbs20)

## Requirements

* SANE Scanner
* Linux host (or VM with necessary pass-through e.g. USB)
* Software sane-utils, ImageMagick, Tesseract (optional) and nodejs
Expand All @@ -51,6 +53,7 @@ Copyright 2016-2021 [Sam Strachan](https://github.com/sbs20)
* [Configuring the scanner and SANE](docs/sane.md)

## Configuration and device override

If you want to override some specific configuration setting then you can do so
within `./config/config.local.js`. Take a copy of `./config/config.default.js`
and override the sections you want. Using docker you will need to map the volume
Expand Down Expand Up @@ -100,6 +103,7 @@ module.exports = {
```

## Why?

This is yet another scanimage-web-front-end. Why? It originally started as an
adaptation of phpsane - just to make everything a bit newer, give it a refresh
and make it work on minimal installations without imagemagick - that version is
Expand All @@ -108,11 +112,13 @@ maintained. Since then, I just wanted to write it in node and enhance it a bit,
and it's been a labour of love ever since.

## Acknowledgements

* This project owes its genesis to
[phpsane](http://sourceforge.net/projects/phpsane/)
* [Everyone](https://github.com/sbs20/scanservjs/graphs/contributors) who has
filed issues, tested, fixed issues, added translations and helped over the
years. Thank you!

## More about SANE

* http://www.sane-project.org/
4 changes: 4 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
```

## Run for development

```
cd webui && npm run serve
```
Expand All @@ -31,10 +32,12 @@ cd server && gulp release
```

## Updating node dependencies

* `npm audit fix` or `npm update`. This won't remove old packages; to do so,
delete node_modules and reinstall

## References

* [Run server with webpack](https://dennisreimann.de/articles/vue-cli-serve-express.html)
* [i18n](https://www.codeandweb.com/babeledit/tutorials/how-to-translate-your-vue-app-with-vue-i18n)

Expand Down Expand Up @@ -82,6 +85,7 @@ docker image prune
```

## Mount map configuration files

```
docker run -d \
-p 8080:8080 \
Expand Down
2 changes: 2 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ docker run -d \
```

### Use airscan and a locally detected scanner

This should support most use cases

```sh
Expand All @@ -136,6 +137,7 @@ docker run -d -p 8080:8080 \
```

### A bit of everything

Add two net hosts to sane, use airscan to connect to two remote scanners, don't
use `scanimage -L`, force a list of devices, override the OCR language and run
in privileged mode
Expand Down
11 changes: 5 additions & 6 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# installation
# Standard installation

The easiest way to run is with Docker. But it's still possible to setup
manually.

## Manual Steps
## One line install

* If you don't already have your scanner working, then you need to get
[SANE installed and working](./sane.md) and check permissions etc. Your
Expand All @@ -17,7 +14,7 @@ manually.
* If you're using another distro, then for the time being you either need to
manually run the steps in the install script or use docker.
## Download and install
## Manual download and install
If you don't fancy running a script directly from `curl` then you can manually
download the package and then run the installer inside.
Expand Down Expand Up @@ -52,6 +49,7 @@ debug where the problem is:
`sudo journalctl -e -u scanservjs` should be enough to get you started.
## Old Debian
For more on problems installing an up to date nodejs on Debian which includes
`npm`. See
[here](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
Expand All @@ -72,5 +70,6 @@ See
for more details.

## Arch

If you're using Arch, you probably don't need help but this worked a few years
ago `sudo pacman -S nodejs npm sane-utils imagemagick curl`
2 changes: 2 additions & 0 deletions docs/sane.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ then feel free to raise and issues or PR.
* `scanimage -L`
### Get permissions working
Pretend to be httpduser
```
sudo -i -u httpdusr
Expand Down Expand Up @@ -172,6 +173,7 @@ chgrp scanner /proc/usb/003/003
```
## Raspberry Pi
USB-only scanners draw a lot of current relative to the Pi's available power.
This can manifest itself in unusual scans - technically valid images but with
odd colours and block transforms. Consider using a powered USB hub (e.g. for a
Expand Down
7 changes: 5 additions & 2 deletions server/bin/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ install() {
if [ -d "$location" ]; then
# keep config and data
mkdir -p $tmp
cp -a -v $location/config $tmp
cp -a -v $location/data $tmp

echo "Backing up existing files"
cp -a $location/config $tmp
cp -a $location/data $tmp

# stop the service
if [ "$(systemctl is-active scanservjs 2>&1 | tr -s \\n)" = "active" ]; then
Expand Down Expand Up @@ -70,6 +72,7 @@ install() {

# Restore files
if [ -d "$tmp" ]; then
echo "Restoring files"
cp -a -v $tmp/config $location/
cp -a -v $tmp/data $location/
fi
Expand Down
2 changes: 1 addition & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scanservjs-server",
"version": "2.9.0",
"version": "2.9.1",
"description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation. scanserv does not do image conversion or manipulation (beyond the bare minimum necessary for the purposes of browser preview) or OCR.",
"scripts": {
"serve": "nodemon --exec 'vue-cli-service serve'",
Expand Down
6 changes: 3 additions & 3 deletions server/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ class Config {

filters: [
{
description: 'filters:auto-level',
description: 'filter.auto-level',
params: '-auto-level'
},
{
description: 'filters:threshold',
description: 'filter.threshold',
params: '-channel RGB -threshold 80%'
},
{
description: 'filters:blur',
description: 'filter.blur',
params: '-blur 1'
}
],
Expand Down
2 changes: 1 addition & 1 deletion server/src/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Config = require('./config');
* @returns {number}
*/
function round(n) {
return Math.floor(n);
return Math.floor(n * 10) / 10;
}

class Feature {
Expand Down
42 changes: 21 additions & 21 deletions server/test/device.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Device', () => {
assert.strictEqual(device.features['-x'].default, 103);
assert.strictEqual(device.features['-y'].limits[0], 0);
assert.strictEqual(device.features['-y'].limits[1], 297);
assert.strictEqual(device.features['-y'].default, 76);
assert.strictEqual(device.features['-y'].default, 76.2);
assert.strictEqual(device.features['--brightness'].limits[0], -100);
assert.strictEqual(device.features['--brightness'].limits[1], 100);
assert.strictEqual(device.features['--brightness'].interval, 1);
Expand All @@ -47,17 +47,17 @@ describe('Device', () => {
assert.deepStrictEqual(device.features['--resolution'].options, [75, 300, 600, 1200]);
assert.strictEqual(device.features['--resolution'].default, 75);
assert.strictEqual(device.features['-l'].limits[0], 0);
assert.strictEqual(device.features['-l'].limits[1], 215);
assert.strictEqual(device.features['-l'].limits[1], 215.9);
assert.strictEqual(device.features['-l'].default, 0);
assert.strictEqual(device.features['-t'].limits[0], 0);
assert.strictEqual(device.features['-t'].limits[1], 297);
assert.strictEqual(device.features['-t'].limits[1], 297.1);
assert.strictEqual(device.features['-t'].default, 0);
assert.strictEqual(device.features['-x'].limits[0], 0);
assert.strictEqual(device.features['-x'].limits[1], 215);
assert.strictEqual(device.features['-x'].default, 215);
assert.strictEqual(device.features['-x'].limits[1], 215.9);
assert.strictEqual(device.features['-x'].default, 215.9);
assert.strictEqual(device.features['-y'].limits[0], 0);
assert.strictEqual(device.features['-y'].limits[1], 297);
assert.strictEqual(device.features['-y'].default, 297);
assert.strictEqual(device.features['-y'].limits[1], 297.1);
assert.strictEqual(device.features['-y'].default, 297.1);
assert.strictEqual(device.features['--brightness'], undefined);
assert.strictEqual(device.features['--contrast'], undefined);
});
Expand All @@ -73,13 +73,13 @@ describe('Device', () => {
assert.deepStrictEqual(device.features['--resolution'].options, [75, 300, 600, 1200]);
assert.strictEqual(device.features['--resolution'].default, 75);
assert.strictEqual(device.features['-l'].limits[0], 0);
assert.strictEqual(device.features['-l'].limits[1], 215);
assert.strictEqual(device.features['-l'].limits[1], 215.9);
assert.strictEqual(device.features['-t'].limits[0], 0);
assert.strictEqual(device.features['-t'].limits[1], 297);
assert.strictEqual(device.features['-t'].limits[1], 297.1);
assert.strictEqual(device.features['-x'].limits[0], 0);
assert.strictEqual(device.features['-x'].limits[1], 215);
assert.strictEqual(device.features['-x'].limits[1], 215.9);
assert.strictEqual(device.features['-y'].limits[0], 0);
assert.strictEqual(device.features['-y'].limits[1], 297);
assert.strictEqual(device.features['-y'].limits[1], 297.1);
assert.strictEqual(device.features['--brightness'].limits[0], -50);
assert.strictEqual(device.features['--brightness'].limits[1], 50);
assert.strictEqual(device.features['--brightness'].interval, 1);
Expand All @@ -102,13 +102,13 @@ describe('Device', () => {
assert.deepStrictEqual(device.features['--resolution'].options, [75, 100, 150, 200, 300, 600, 1200]);
assert.strictEqual(device.features['--resolution'].default, 150);
assert.strictEqual(device.features['-l'].limits[0], 0);
assert.strictEqual(device.features['-l'].limits[1], 215);
assert.strictEqual(device.features['-l'].limits[1], 215.9);
assert.strictEqual(device.features['-t'].limits[0], 0);
assert.strictEqual(device.features['-t'].limits[1], 297);
assert.strictEqual(device.features['-t'].limits[1], 297.1);
assert.strictEqual(device.features['-x'].limits[0], 0);
assert.strictEqual(device.features['-x'].limits[1], 215);
assert.strictEqual(device.features['-x'].limits[1], 215.9);
assert.strictEqual(device.features['-y'].limits[0], 0);
assert.strictEqual(device.features['-y'].limits[1], 297);
assert.strictEqual(device.features['-y'].limits[1], 297.1);
assert.strictEqual(device.features['--brightness'], undefined);
assert.strictEqual(device.features['--contrast'], undefined);
});
Expand All @@ -127,11 +127,11 @@ describe('Device', () => {
assert.strictEqual(device.features['-l'].limits[0], 0);
assert.strictEqual(device.features['-l'].limits[1], 216);
assert.strictEqual(device.features['-t'].limits[0], 0);
assert.strictEqual(device.features['-t'].limits[1], 355);
assert.strictEqual(device.features['-t'].limits[1], 355.6);
assert.strictEqual(device.features['-x'].limits[0], 0);
assert.strictEqual(device.features['-x'].limits[1], 216);
assert.strictEqual(device.features['-y'].limits[0], 0);
assert.strictEqual(device.features['-y'].limits[1], 355);
assert.strictEqual(device.features['-y'].limits[1], 355.6);
assert.strictEqual(device.features['--brightness'], undefined);
assert.strictEqual(device.features['--contrast'], undefined);
});
Expand All @@ -148,13 +148,13 @@ describe('Device', () => {
assert.deepStrictEqual(device.features['--resolution'].options, [100, 150, 200, 300, 400, 600, 1200, 2400, 4800, 9600]);
assert.strictEqual(device.features['--resolution'].default, 200);
assert.strictEqual(device.features['-l'].limits[0], 0);
assert.strictEqual(device.features['-l'].limits[1], 215);
assert.strictEqual(device.features['-l'].limits[1], 215.9);
assert.strictEqual(device.features['-t'].limits[0], 0);
assert.strictEqual(device.features['-t'].limits[1], 355);
assert.strictEqual(device.features['-t'].limits[1], 355.6);
assert.strictEqual(device.features['-x'].limits[0], 0);
assert.strictEqual(device.features['-x'].limits[1], 215);
assert.strictEqual(device.features['-x'].limits[1], 215.9);
assert.strictEqual(device.features['-y'].limits[0], 0);
assert.strictEqual(device.features['-y'].limits[1], 355);
assert.strictEqual(device.features['-y'].limits[1], 355.6);
assert.strictEqual(device.features['--brightness'], undefined);
assert.strictEqual(device.features['--contrast'], undefined);
});
Expand Down
4 changes: 2 additions & 2 deletions server/test/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe('Request', () => {
assert.strictEqual(request.params.resolution, '150');
assert.strictEqual(request.params.left, 0);
assert.strictEqual(request.params.top, 0);
assert.strictEqual(request.params.width, 215);
assert.strictEqual(request.params.height, 297);
assert.strictEqual(request.params.width, 215.9);
assert.strictEqual(request.params.height, 297.1);
assert.strictEqual(request.params.brightness, undefined);
assert.strictEqual(request.params.contrast, undefined);
assert.strictEqual(request.params.dynamicLineart, undefined);
Expand Down
Loading

0 comments on commit 938a9b0

Please sign in to comment.