From 1e63e8ceaeb796d792bf0ce3bca547c0cf9a56de Mon Sep 17 00:00:00 2001 From: xeijin Date: Fri, 7 Jan 2022 00:41:48 +0000 Subject: [PATCH 01/14] Insaned & scanservjs Enable hardware scan button to launch a scanservjs scan (compatible scanners only) --- docs/integration.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/integration.md b/docs/integration.md index 38ef5bc6..249b2d4e 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -11,6 +11,13 @@ free to integrate however you want. The recommended way is to create a script or program which scans the output directory for files and then does something with them. +## insanebd + +Use your scanner's hardware 'Scan' button to initiate a new scan via `scanservjs` +https://gitlab.com/xeijin-dev/insaned + +Requires a scanner that exposes buttons as sensors and `curl`. + ## paperless-ng [This discussion](https://github.com/sbs20/scanservjs/issues/351#issuecomment-913858423) From 0b485510cb89392794e4c437c68964f20054c907 Mon Sep 17 00:00:00 2001 From: xeijin Date: Fri, 7 Jan 2022 00:44:03 +0000 Subject: [PATCH 02/14] fix md formatting --- docs/integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integration.md b/docs/integration.md index 249b2d4e..4c4e7550 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -11,7 +11,7 @@ free to integrate however you want. The recommended way is to create a script or program which scans the output directory for files and then does something with them. -## insanebd +## insaned Use your scanner's hardware 'Scan' button to initiate a new scan via `scanservjs` https://gitlab.com/xeijin-dev/insaned From 1e526998ca5e0492153d338d34487cd6e0d423e1 Mon Sep 17 00:00:00 2001 From: xeijin Date: Fri, 7 Jan 2022 00:44:25 +0000 Subject: [PATCH 03/14] fix md formatting --- docs/integration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/integration.md b/docs/integration.md index 4c4e7550..f4116d6b 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -14,6 +14,7 @@ directory for files and then does something with them. ## insaned Use your scanner's hardware 'Scan' button to initiate a new scan via `scanservjs` + https://gitlab.com/xeijin-dev/insaned Requires a scanner that exposes buttons as sensors and `curl`. From cce1422778e9a931ce2d3514ee30e0318f8189e8 Mon Sep 17 00:00:00 2001 From: Ibon Castilla Varela Date: Wed, 26 Jan 2022 11:03:54 +0100 Subject: [PATCH 04/14] Update Spanish translation --- packages/client/src/locales/es.json | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/client/src/locales/es.json b/packages/client/src/locales/es.json index 31651520..42f0da73 100644 --- a/packages/client/src/locales/es.json +++ b/packages/client/src/locales/es.json @@ -6,7 +6,7 @@ "about": { "main": "scanservjs es una interfaz gráfica simple y basada en web. Permite compartir uno o mas escáneres (utilizando SANE) en una red sin la necesidad de controladores adicionales o una instalación complicada. Permite guardar en formato TIF, JPG, PNG, PDF, y TXT (con Tesseract OCR) con varias configuraciones de compresión, todas ellas configurables. Soporta el escaneo multipágina y todos los dispositivos SANE compatibles.", "issue": "Indicar una incidencia o ver el código fuente:", - "system-info": "System information" + "system-info": "Información del sistema" }, "colors": { @@ -43,15 +43,15 @@ "filename": "Nombre de fichero", "date": "Fecha", "size": "Tamaño", - "items-per-page": "Files per page", - "items-per-page-all": "All", + "items-per-page": "Ficheros por página", + "items-per-page-all": "Todos", "message:deleted": "Borrado {0}", - "message:renamed": "File renamed", - "button:delete-selected": "Delete Selected", - "dialog:rename": "Change file name", - "dialog:rename-cancel": "Cancel", - "dialog:rename-save": "Save", - "actions": "Actions" + "message:renamed": "Fichero renombrado", + "button:delete-selected": "Eliminar seleccionados", + "dialog:rename": "Renombrar", + "dialog:rename-cancel": "Cancelar", + "dialog:rename-save": "Guardar", + "actions": "Acciones" }, "navigation": { @@ -116,14 +116,14 @@ }, "paper-size": { - "letter": "Letter", - "legal": "Legal", - "tabloid": "Tabloid", - "ledger": "Ledger", - "junior-legal": "Junior legal", - "half-letter": "Half letter", - "portrait": "Portrait", - "landscape": "Landscape" + "letter": "Letter (216 × 279 mm)", + "legal": "Legal (216 × 356 mm)", + "tabloid": "Tabloid (279 × 432 mm)", + "ledger": "Ledger (432 × 279 mm)", + "junior-legal": "Junior legal (127 × 203 mm)", + "half-letter": "Half letter (140 × 216 mm)", + "portrait": "Retrato", + "landscape": "Apaisado" }, "scan": { From 2e4acf933199aaa91f10188b0129beae3d766ec2 Mon Sep 17 00:00:00 2001 From: David Ward Date: Mon, 31 Jan 2022 20:58:02 -0500 Subject: [PATCH 05/14] Switch order of operations when updating preview image Resize the scanned image first, and then adjust its extents based on the scan area (when the device geometry is known). The resulting preview image will be exactly the same, but this involves significantly less processing, especially for scans at high resolution. --- packages/server/src/scan-controller.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/server/src/scan-controller.js b/packages/server/src/scan-controller.js index bf1394af..5139672b 100644 --- a/packages/server/src/scan-controller.js +++ b/packages/server/src/scan-controller.js @@ -129,22 +129,23 @@ class ScanController { * @returns {Promise.} */ async updatePreview(filename) { - const dpmm = this.request.params.resolution / 25.4; + const previewWidth = 868; const device = this.context.getDevice(this.request.params.deviceId); const cmdBuilder = new CmdBuilder(Config.convert).arg(`'${Config.tempDirectory}/${filename}'`); if (device.geometry) { - const geometry = { - width: device.features['-x'].limits[1] * dpmm, - height: device.features['-y'].limits[1] * dpmm, - left: this.request.params.left * dpmm, - top: this.request.params.top * dpmm - }; - cmdBuilder.arg('-background', '#808080') - .arg('-extent', `${geometry.width}x${geometry.height}-${geometry.left}-${geometry.top}`); + const previewScale = previewWidth / device.features['-x'].limits[1]; + const previewHeight = Math.round(device.features['-y'].limits[1] * previewScale); + const left = Math.round(this.request.params.left * previewScale); + const top = Math.round(this.request.params.top * previewScale); + const width = Math.round(this.request.params.width * previewScale); + cmdBuilder.arg('-resize', width) + .arg('-background', '#808080') + .arg('-extent', `${previewWidth}x${previewHeight}-${left}-${top}`); + } else { + cmdBuilder.arg('-resize', previewWidth); } - cmdBuilder.arg('-resize', 868) - .arg(`'${Config.previewDirectory}/preview.tif'`); + cmdBuilder.arg(`'${Config.previewDirectory}/preview.tif'`); await Process.spawn(cmdBuilder.build()); } From 73df8aedd8670f06d28987e59273b1dbd0846e31 Mon Sep 17 00:00:00 2001 From: David Ward Date: Fri, 4 Feb 2022 08:25:46 -0500 Subject: [PATCH 06/14] Use faster resize operator when updating preview image Change "-resize" to "-scale". This has been tested to reduce the processing time by an order of magnitude without a noticeable change in image quality. --- packages/server/src/scan-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/scan-controller.js b/packages/server/src/scan-controller.js index 5139672b..303437b4 100644 --- a/packages/server/src/scan-controller.js +++ b/packages/server/src/scan-controller.js @@ -138,11 +138,11 @@ class ScanController { const left = Math.round(this.request.params.left * previewScale); const top = Math.round(this.request.params.top * previewScale); const width = Math.round(this.request.params.width * previewScale); - cmdBuilder.arg('-resize', width) + cmdBuilder.arg('-scale', width) .arg('-background', '#808080') .arg('-extent', `${previewWidth}x${previewHeight}-${left}-${top}`); } else { - cmdBuilder.arg('-resize', previewWidth); + cmdBuilder.arg('-scale', previewWidth); } cmdBuilder.arg(`'${Config.previewDirectory}/preview.tif'`); From 0ccaa3081874e6ba409aa920806337b162444a66 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 09:46:03 +0000 Subject: [PATCH 07/14] Small refactor --- packages/server/src/scan-controller.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/server/src/scan-controller.js b/packages/server/src/scan-controller.js index 303437b4..f168b93b 100644 --- a/packages/server/src/scan-controller.js +++ b/packages/server/src/scan-controller.js @@ -129,20 +129,22 @@ class ScanController { * @returns {Promise.} */ async updatePreview(filename) { - const previewWidth = 868; const device = this.context.getDevice(this.request.params.deviceId); - const cmdBuilder = new CmdBuilder(Config.convert).arg(`'${Config.tempDirectory}/${filename}'`); + const cmdBuilder = new CmdBuilder(Config.convert) + .arg(`'${Config.tempDirectory}/${filename}'`); + + const width = 868; if (device.geometry) { - const previewScale = previewWidth / device.features['-x'].limits[1]; - const previewHeight = Math.round(device.features['-y'].limits[1] * previewScale); - const left = Math.round(this.request.params.left * previewScale); - const top = Math.round(this.request.params.top * previewScale); - const width = Math.round(this.request.params.width * previewScale); - cmdBuilder.arg('-scale', width) + const scale = width / device.features['-x'].limits[1]; + const height = Math.round(device.features['-y'].limits[1] * scale); + const left = Math.round(this.request.params.left * scale); + const top = Math.round(this.request.params.top * scale); + const scaleWidth = Math.round(this.request.params.width * scale); + cmdBuilder.arg('-scale', scaleWidth) .arg('-background', '#808080') - .arg('-extent', `${previewWidth}x${previewHeight}-${left}-${top}`); + .arg('-extent', `${width}x${height}-${left}-${top}`); } else { - cmdBuilder.arg('-scale', previewWidth); + cmdBuilder.arg('-scale', width); } cmdBuilder.arg(`'${Config.previewDirectory}/preview.tif'`); From 608d93791a92889042515cde31dc0191199c03a5 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 09:52:14 +0000 Subject: [PATCH 08/14] Docker ARM #384 #372 --- .github/workflows/docker.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8ce9e47b..f87356be 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,6 +19,9 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 + - name: Set up QEMU for multi-platform build + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -35,6 +38,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:staging target: scanservjs-core + platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Push master if: github.ref == 'refs/heads/master' @@ -43,6 +47,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:latest target: scanservjs-core + platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Get version id: get_version @@ -56,3 +61,4 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:release-${{ steps.get_version.outputs.VERSION }} target: scanservjs-core + platforms: linux/amd64,linux/arm64,linux/arm/v7 From f04b4f1d459605e7a60f6ff948618330052db261 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 09:54:00 +0000 Subject: [PATCH 09/14] Docker hplib #384 --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index 69607b4a..8b0c01e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -95,3 +95,14 @@ USER $UNAME # default build FROM scanservjs-core + +# hplip image +# +# This image adds the HP scanner libs to the image. This target is not built by +# default - you will need to specifically target it. +# ============================================================================== +FROM scanservjs-core AS scanservjs-hplip +RUN apt-get install -yq libsane-hpaio \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && echo hpaio >> /etc/sane.d/dll.conf From d0284a87fba3726d74b123e767c8663b889b2eec Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 10:02:12 +0000 Subject: [PATCH 10/14] Reformat --- docs/integration.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/integration.md b/docs/integration.md index f4116d6b..26376761 100644 --- a/docs/integration.md +++ b/docs/integration.md @@ -11,14 +11,6 @@ free to integrate however you want. The recommended way is to create a script or program which scans the output directory for files and then does something with them. -## insaned - -Use your scanner's hardware 'Scan' button to initiate a new scan via `scanservjs` - -https://gitlab.com/xeijin-dev/insaned - -Requires a scanner that exposes buttons as sensors and `curl`. - ## paperless-ng [This discussion](https://github.com/sbs20/scanservjs/issues/351#issuecomment-913858423) @@ -30,6 +22,13 @@ about paperless-ng resulted in You could integrate with Dropbox using [Dropbox-Uploader](https://github.com/andreafabrizi/Dropbox-Uploader) +## insaned + +Use your scanner's hardware 'Scan' button to initiate a new scan via +`scanservjs`. Requires a scanner that exposes buttons as sensors and `curl`. + +* Repo: https://gitlab.com/xeijin-dev/insaned + ## Recipe for Scan2Cloud This recipe covers all major cloud providers such as Amazon, Dropbox, Google From a3e411118a399b8d7369856e740fee4f7d7ca184 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 10:33:45 +0000 Subject: [PATCH 11/14] Doc updates --- README.md | 3 ++- docs/docker.md | 22 +++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 24e9ade0..04e0e197 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ![screenshot](https://github.com/sbs20/scanservjs/raw/master/docs/screen0.jpg) -Copyright 2016-2021 [Sam Strachan](https://github.com/sbs20) +Copyright 2016-2022 [Sam Strachan](https://github.com/sbs20) ## What people are saying @@ -52,6 +52,7 @@ complicated installation. [Help requested](https://github.com/sbs20/scanservjs/issues/154) * Light and dark mode * Responsive design +* Docker images for `amd64`, `arm64` and `armv7` It supports any [SANE compatible devices](http://www.sane-project.org/sane-supported-devices.html). diff --git a/docs/docker.md b/docs/docker.md index a6d6b99a..da0ebdcf 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -29,9 +29,7 @@ docker run -d \ * ⚠ By default, configuration and scanned images are stored within the container and will be lost if you recreate it. If you want to map your scanned images then see mapping section below -* ⚠ The docker image is amd64 only - and will not work on ARM devices such as - the Raspberry Pi. Please follow the manual installation process in these - cases +* ✅ The docker image now supports arm as well as amd64. ## Accessing hardware @@ -110,24 +108,22 @@ wish to map: When mapping volumes, special attention must be paid to users and file systems permissions. -The docker container runs under a non-privileged user with a UID and GID of -`2001`. scanservjs relies on this user for editing SANE and airscan -configurations inside the container. Changing this user's UID (e.g. by using -`-u 1000` for `docker run`) to access scans/configuration from outside docker -**is not advised since it will cause these steps to fail.** +The docker container runs as root by default. Changing the user's UID (e.g. by +using `-u 1000` for `docker run`) to access scans/configuration from outside +docker **is not advised since it will cause scans to fail.**. If running as a +different user is important to you then see the `scanservjs-user2001` target in +[../Dockerfile](../Dockerfile). Your alternatives are: 1. changing the group of the container to a known group on the host e.g. - `-u 2001:1000`. This will keep the user correct (`2001`) but change the group + `-u 0:1000`. This will keep the user correct (`0`) but change the group (`1000`). -2. creating a corresponding user on the host e.g. - `useradd -u 2001 -ms /bin/bash scanservjs` -3. building a docker image with a custom UID/GID pairing: clone this repository +2. building a docker image with a custom UID/GID pairing: clone this repository and run `docker build --build-arg UID=1234 --build-arg GID=5678 -t scanservjs_custom .` (with UID and GID adjusted to your liking), then run the custom image (e.g. `docker run scanservjs_custom`). -4. as a last resort, changing the host volume permissions e.g. +3. as a last resort, changing the host volume permissions e.g. `chmod 777 local-volume` ## Environment variables From 4d15a21ace45fab6ea82179f3afd4f2d5bd98853 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 10:34:04 +0000 Subject: [PATCH 12/14] Version bump --- package-lock.json | 4 ++-- package.json | 2 +- packages/client/package-lock.json | 4 ++-- packages/client/package.json | 2 +- packages/server/package-lock.json | 4 ++-- packages/server/package.json | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index f834f17b..f97f01cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "scanservjs", - "version": "2.19.1", + "version": "2.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scanservjs", - "version": "2.19.1", + "version": "2.20.0", "hasInstallScript": true, "license": "GPL-2.0" } diff --git a/package.json b/package.json index fccec7b6..6067126d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scanservjs", - "version": "2.19.1", + "version": "2.20.0", "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.", "scripts": { "clean": "rm -rf ./dist", diff --git a/packages/client/package-lock.json b/packages/client/package-lock.json index febcf358..15b8f429 100644 --- a/packages/client/package-lock.json +++ b/packages/client/package-lock.json @@ -1,12 +1,12 @@ { "name": "scanservjs", - "version": "2.19.1", + "version": "2.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scanservjs", - "version": "2.19.1", + "version": "2.20.0", "license": "GPL-2.0", "dependencies": { "@mdi/font": "^5.9.55", diff --git a/packages/client/package.json b/packages/client/package.json index 4c915a91..2399e225 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "scanservjs", - "version": "2.19.1", + "version": "2.20.0", "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.", "author": "Sam Strachan", "scripts": { diff --git a/packages/server/package-lock.json b/packages/server/package-lock.json index 76ec5fa2..7d6fb218 100644 --- a/packages/server/package-lock.json +++ b/packages/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "scanservjs-server", - "version": "2.19.1", + "version": "2.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scanservjs-server", - "version": "2.19.1", + "version": "2.20.0", "license": "GPL-2.0", "dependencies": { "adm-zip": "^0.5.5", diff --git a/packages/server/package.json b/packages/server/package.json index 8442b53e..5112784e 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "scanservjs-server", - "version": "2.19.1", + "version": "2.20.0", "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.", "scripts": { "lint": "gulp lint", From 03217c064b57bbc330727b74ca41fb59ed7e543b Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 10:47:19 +0000 Subject: [PATCH 13/14] Docker i386 #367 --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f87356be..24f252c4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -38,7 +38,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:staging target: scanservjs-core - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 - name: Push master if: github.ref == 'refs/heads/master' @@ -47,7 +47,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:latest target: scanservjs-core - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 - name: Get version id: get_version @@ -61,4 +61,4 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:release-${{ steps.get_version.outputs.VERSION }} target: scanservjs-core - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 From 0499ea716c2ff1023da85818be6485bb2669cffb Mon Sep 17 00:00:00 2001 From: sbs20 Date: Tue, 15 Feb 2022 10:56:33 +0000 Subject: [PATCH 14/14] Abort #367 --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 24f252c4..f87356be 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -38,7 +38,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:staging target: scanservjs-core - platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 + platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Push master if: github.ref == 'refs/heads/master' @@ -47,7 +47,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:latest target: scanservjs-core - platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 + platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Get version id: get_version @@ -61,4 +61,4 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:release-${{ steps.get_version.outputs.VERSION }} target: scanservjs-core - platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 + platforms: linux/amd64,linux/arm64,linux/arm/v7