Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use less CPU and RAM #549

Merged
merged 4 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FROM node:16-bullseye-slim AS scanservjs-base
RUN apt-get update \
&& apt-get install -yq \
imagemagick \
img2pdf \
sane \
sane-utils \
tesseract-ocr \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ It supports any

* SANE Scanner
* Linux host (or VM with necessary pass-through e.g. USB)
* Software sane-utils, ImageMagick, Tesseract (optional) and nodejs
* Software sane-utils, ImageMagick, img2pdf, Tesseract (optional) and nodejs

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```shell
# Install dependencies
sudo apt-get install curl nodejs npm imagemagick sane-utils tesseract-ocr
sudo apt-get install curl nodejs npm imagemagick img2pdf sane-utils tesseract-ocr

# Ideally set the npm version
sudo npm install npm@8.3.0 -g
Expand Down
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ For more on problems installing an up to date nodejs on Debian which includes
```console
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt install -y nodejs
sudo apt-get install npm sane-utils imagemagick
sudo apt-get install npm sane-utils imagemagick img2pdf
```

Debian calls the node binary "nodejs", which results in npm not being able to
Expand All @@ -96,4 +96,4 @@ 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`
ago `sudo pacman -S nodejs npm sane-utils imagemagick img2pdf curl`
6 changes: 3 additions & 3 deletions docs/sane.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SANE, imagemagick, scanners
# SANE, imagemagick, img2pdf, scanners

## Install

Just use your package manager.

* Debian / Ubuntu / Raspbian: `sudo apt install sane-utils imagemagick`
* Debian / Ubuntu / Raspbian: `sudo apt install sane-utils imagemagick img2pdf`
* Arch: `sudo pacman -S sane`

## Validate SANE is working
Expand Down Expand Up @@ -137,7 +137,7 @@ then feel free to raise and issues or PR.
* Type `lsusb` to check the scanner is attached
* At the terminal type the following commands
* `opkg update`
* `opkg install sane-frontends imagemagick sudo`
* `opkg install sane-frontends imagemagick img2pdf sudo`
* Confirm installation typing...
* `sane-find-scanner -q`
* `scanimage -L`
Expand Down
6 changes: 4 additions & 2 deletions packages/server/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ install() {
nodejs \
npm \
imagemagick \
img2pdf \
sane-utils \
tesseract-ocr \
tesseract-ocr-ara \
Expand Down Expand Up @@ -132,7 +133,7 @@ $ netstat -tulpn | grep :8080 --->
$(netstat -tulpn | grep ":8080\s")

Either
* update the port in $location/config/config.local.js or
* update the port in $location/config/config.local.js or
* Stop the other program

After that you can just enable and start:
Expand Down Expand Up @@ -183,6 +184,7 @@ hard_uninstall() {
npm \
imagemagick \
sane-utils \
img2pdf \
tesseract-ocr
}

Expand Down Expand Up @@ -217,7 +219,7 @@ scanservjs: https://github.com/sbs20/scanservjs
Install runs through the following steps

* run apt-get update
* install SANE, node and imagemagick dependencies
* install SANE, node, imagemagick and img2pdf dependencies
* create the web application in /var/www/scanservjs
* create a user and systemd service which is enabled and started

Expand Down
32 changes: 16 additions & 16 deletions packages/server/src/classes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,91 +118,91 @@ module.exports = class Config {
extension: 'jpg',
description: 'JPG | @:pipeline.high-quality',
commands: [
'convert @- -quality 92 scan-%04d.jpg',
'while read filename ; do convert -quality 92 $filename scan-$(date +%s.%N).jpg ; done',
'ls scan-*.*'
]
},
{
extension: 'jpg',
description: 'JPG | @:pipeline.medium-quality',
commands: [
'convert @- -quality 75 scan-%04d.jpg',
'while read filename ; do convert -quality 75 $filename scan-$(date +%s.%N).jpg ; done',
'ls scan-*.*'
]
},
{
extension: 'jpg',
description: 'JPG | @:pipeline.low-quality',
commands: [
'convert @- -quality 50 scan-%04d.jpg',
'while read filename ; do convert -quality 50 $filename scan-$(date +%s.%N).jpg ; done',
'ls scan-*.*'
]
},
{
extension: 'png',
description: 'PNG',
commands: [
'convert @- -quality 75 scan-%04d.png',
'while read filename ; do convert -quality 75 $filename scan-$(date +%s.%N).png ; done',
'ls scan-*.*'
]
},
{
extension: 'tif',
description: 'TIF | @:pipeline.uncompressed',
commands: [
'convert @- scan-0000.tif',
'while read filename ; do convert $filename scan-$(date +%s.%N).tif ; done',
'ls scan-*.*'
]
},
{
extension: 'tif',
description: 'TIF | @:pipeline.lzw-compressed',
commands: [
'convert @- -compress lzw scan-0000.tif',
'while read filename ; do convert -compress lzw $filename scan-$(date +%s.%N).tif ; done',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (TIF | @:pipeline.uncompressed)',
commands: [
'convert @- scan-0000.pdf',
'xargs img2pdf --output scan-0000.pdf',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (TIF | @:pipeline.lzw-compressed)',
commands: [
'convert @- -compress lzw tmp-%04d.tif && ls tmp-*.tif',
'convert @- scan-0000.pdf',
'while read filename ; do convert -compress lzw $filename converted-$(date +%s.%N).tif ; done',
'img2pdf --output scan-0000.pdf $(ls -v converted-*.tif)',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (JPG | @:pipeline.high-quality)',
commands: [
'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
'while read filename ; do convert -quality 92 $filename converted-$(date +%s.%N).jpg ; done',
'img2pdf --output scan-0000.pdf $(ls -v *.jpg)',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (JPG | @:pipeline.medium-quality)',
commands: [
'convert @- -quality 75 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
'while read filename ; do convert -quality 75 $filename converted-$(date +%s.%N).jpg ; done',
'img2pdf --output scan-0000.pdf $(ls -v *.jpg)',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (JPG | @:pipeline.low-quality)',
commands: [
'convert @- -quality 50 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
'while read filename ; do convert -quality 50 $filename converted-$(date +%s.%N).jpg ; done',
'img2pdf --output scan-0000.pdf $(ls -v *.jpg)',
'ls scan-*.*'
]
},
Expand All @@ -211,7 +211,7 @@ module.exports = class Config {
description: '@:pipeline.ocr | PDF (JPG | @:pipeline.high-quality)',
get commands() {
return [
'convert @- -quality 92 tmp-%d.jpg && ls tmp-*.jpg',
'while read filename ; do convert -quality 92 $filename tmp-$(date +%s.%N).jpg ; done && ls tmp-*.jpg',
`${config.tesseract} -l ${config.ocrLanguage} -c stream_filelist=true - - pdf > scan-0001.pdf`,
'ls scan-*.*'
];
Expand Down