Skip to content

Commit

Permalink
Merge pull request #395 from sbs20/development
Browse files Browse the repository at this point in the history
Localisation, faster preview, docker arm
  • Loading branch information
sbs20 authored Feb 15, 2022
2 parents 086663d + 03217c0 commit 38e4742
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 52 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -35,6 +38,7 @@ jobs:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:staging
target: scanservjs-core
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386

- name: Push master
if: github.ref == 'refs/heads/master'
Expand All @@ -43,6 +47,7 @@ jobs:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/scanservjs:latest
target: scanservjs-core
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386

- name: Get version
id: get_version
Expand All @@ -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,linux/386
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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).
Expand Down
22 changes: 9 additions & 13 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,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
Expand Down
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/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 packages/client/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
34 changes: 17 additions & 17 deletions packages/client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/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 packages/server/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
27 changes: 15 additions & 12 deletions packages/server/src/scan-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,25 @@ class ScanController {
* @returns {Promise.<void>}
*/
async updatePreview(filename) {
const dpmm = this.request.params.resolution / 25.4;
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 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 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', `${width}x${height}-${left}-${top}`);
} else {
cmdBuilder.arg('-scale', width);
}

cmdBuilder.arg('-resize', 868)
.arg(`'${Config.previewDirectory}/preview.tif'`);
cmdBuilder.arg(`'${Config.previewDirectory}/preview.tif'`);

await Process.spawn(cmdBuilder.build());
}
Expand Down

0 comments on commit 38e4742

Please sign in to comment.