sbs20 / scanservjs Goto Github PK
View Code? Open in Web Editor NEWSANE scanner nodejs web ui
Home Page: https://sbs20.github.io/scanservjs/
License: GNU General Public License v2.0
SANE scanner nodejs web ui
Home Page: https://sbs20.github.io/scanservjs/
License: GNU General Public License v2.0
And include version on screen
Hi,
Could you add hook to the github repository with dockerhub to have a update-to-date docker images ?
The last docker image on the repo is 2years old.
Kind regards,
Hi,
After a shutdown (or reboot) of my raspberry, scanservjs server is not started.
I have to install scanservjs a new time.
After a shutdown of the raspberry :
pi@SPRINT:~ $ wget -O - http://localhost:8080 --2020-10-03 17:57:05-- http://localhost:8080/ Resolving localhost (localhost)... ::1, 127.0.0.1 Connecting to localhost (localhost)|::1|:8080... failed: Connection refused. Connecting to localhost (localhost)|127.0.0.1|:8080... failed: Connection refused.
Version scanservjs : V2.0.3
OS :
pi@SPRINT:~ $ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=raspbian ID_LIKE=debian
I would like to scan several pages and merge them into one PDF
Quite simple, you already have the machinery to call convert and make a jpg out of the file, please apply the same on the scanned file.
I understand you might just want tif, if so please make it a global setting of the app, otherwise a setting in the UI.
Describe the bug
Any setting of brightness or contrast is lost after page refresh in UI
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Brightness/contrast value loaded from localStorage
It seems that although value for brightness and contrast are saved into localStorage, when loaded back in readRequest()
method in Scanserv.vue, it's always set to 0:
...
if ('--brightness' in device.features) {
request.params.brightness = 0;
}
if ('--contrast' in device.features) {
request.params.contrast = 0;
}
...
There are two things that seems to be problematic:
request
value is retrieved from localStoragedevice.features['--brightness'].default
and device.features['--contrast'].default
respectively could be usedHey,
I have the following problem while trying to scan an image using scanservjs and sane.
When ever I try to obtain a preview, scanservjs tries to execute the following command:
scanimage -d "hpaio:/usb/Deskjet_F2400_series?serial=CN03GB749405H4" --mode "Color" --resolution 100 -l 0 -t 0 -x 215 -y 297 --formattiff --brightness 0 --contrast 0 > "./data/preview/preview.tif"
The problem is, that the command throws the following error:
scanimage: unrecognized option '--formattiff'
Also, when I try to directly create a scan, the following error is thrown:
scanimage: setting of option --br-y failed (Invalid argument)
Is there anything wrong here? Keep in mind that I've installed sane locally on my raspberry pi. Should I rather use the provided docker package?
I hope, you can help me with this issue.
package.json update suggested: bootstrap ~> 4.1.2.
It is possible to send a (custom) DELETE
request for a file outside the data/
directory:
Since the server is usually running as an extra user that shouldn't be too much of an issue on a "normal" system (there are hardly any files which can be deleted just by being in users
), but if the system is configurated badly this might cause some harm.
Hi,
Is that possible to create an output format in PDF, like the jpg low quality format ?
Sometimes, it is usefull to scan in PDF with a low quality (and so a "small" file).
It is what you done with the JPG format (we have the choice between : high quality, medium quality, low quality).
Thanks !
USB device address changes across reboots. As a result xscanimage can no longer find the scanner.
Option 1) [reset] should also wipe device.conf so that the UI can rediscover any scanner(s)
Option 2) the systemctl script should remove device.conf on restart
Describe the bug
Conversion to PDF (JPG)
fails with
Error: convert @- -quality 92 tmp-%d.jpg && ls tmp-*.jpg exited with code: 127, stderr: /bin/sh: 1: ls: not found
.
To Reproduce
Steps to reproduce the behavior:
PDF (JPG)
as format.Expected behavior
ls
is found and executed properly.
Server
/bin
, /sbin
, /usr/bin
, etc. are different directories. This might not be the case for every system. Some distributions/setups have only one bin
directory and use links for all other directories.Cause
This is caused by /bin
not being in $PATH
.
scanservjs.service
sets PATH=/usr/bin:/usr/local/bin
(https://github.com/sbs20/scanservjs/blob/staging/scanservjs.service#L10).
It seems like there is no reason for this, as it cannot be used for security limitations or anything like that anyway.
Fixes
Append :/bin
to scanservjs.service
line 10.
Alternatively replace all occurences of ls
with its absolute path (/bin/ls
) in config/config.js
.
In order to improve the automatic parsing of device features and options (partly covered by #6) we need example device.conf files
Some options are represented by ranges (0..100)
others by delimited lists (0|25|50|75|100)
. Some contain units (dpi|mm|bit)
others don't etc. Getting a variety of examples would help.
Here's mine device.conf.txt
See #48
heya,
i'm using scanservjs as an input scanner for my edms papermerge.
scanservjs's output folder is papermerge's input folder.
unfortunately, as soon as scanservjs creates the empty file to be filled with data upon commencement of a scan, papermerge's worker can already grab the file and move it out of the folder.
would it be possible to finish the file in a temporary location and move it into the output folder thereafter? maybe that can be configurable, or system-tmp.
I build it and browse the URL like 'http://192.168.200.200:8080/'.However, the page shows "scanserv.js
Command line testing » exec". It seems I don't have file named 'assets/js/app.js' and 'assets/css/app.css'. Please tell me what should I do?
Hi, the follow command listend on install.md returns an error:
wget -O ~/scanservjs.tar.gz $(curl -s https://api.github.com/repos/sbs20/scanservjs/releases/latest | grep browser_download_url | cut -d '"' -f 4)
Throws wget: missing URL
Describe the bug
If the output folder (/app/data/output/
in the Docker container) is on different mountpoint than the temporary folder, the rename operation after saving a file fails and the file is lost.
To Reproduce
/media/Documents
)-v /media/Documents/Scan/:/app/data/output/
)Log
[2020-12-02T22:23:30.862Z] ERROR (Http): [Error: EXDEV: cross-device link not permitted, rename './data/temp/scan-0001.pdf' -> './data/output/scan_2020-12-02 22.23.30.pdf'] {
errno: -18,
code: 'EXDEV',
syscall: 'rename',
path: './data/temp/scan-0001.pdf',
dest: './data/output/scan_2020-12-02 22.23.30.pdf'
}
Additional context
The problem comes from the fs.rename
call below. The rename syscall on Linux isn't able to rename files across mountpoint boundaries (which, in fairness, does makes sense).
scanservjs/server/file-info.js
Line 71 in 6378858
The usual solution is to try renaming and if that fails, do a proper move operation.
This is conveniently packaged up in the mv package on NPM.
I recommend adding that package (seems like a pretty safe dependency) and replacing the above fs.rename
call with mv
. If that sounds good, I can send a PR this weekend.
Hi,
My skills in linux are poor !
I am not able to install scanservjs docker (You can see bellow the command lines I entered).
When I use the commands, and then when I try to start the web adress http://192.168.1.22:8080, Firefox returns an error !!
Can you help me ?
Jerome
pi@SPRINT:~ $ sudo docker pull sbs20/scanservjs:staging
staging: Pulling from sbs20/scanservjs
d121f8d1c412: Already exists
3a54a24e4e59: Already exists
ab3ac3d6ac3a: Already exists
e9e8e4632961: Already exists
f9026f9b6233: Already exists
f2d31737a4de: Pull complete
814d4b552041: Pull complete
f8603a6d7986: Pull complete
ca2de6e6f185: Pull complete
f27663d472f6: Pull complete
984ed5ed870c: Pull complete
94a5463006ef: Pull complete
Digest: sha256:0c1f1b712338a01980a65e3693e4a7ddbe30640903b055936395ddcb7251ab54
Status: Downloaded newer image for sbs20/scanservjs:staging
docker.io/sbs20/scanservjs:staging
pi@SPRINT:~ $ sudo docker rm --force scanservjs-container 2> /dev/null
scanservjs-container
pi@SPRINT:~ $ sudo docker run -d -p 8080:8080 --restart unless-stopped --name scanservjs-container --privileged sbs20/scanservjs:staging
02824fbdf9be97f6a872f2cbd68367deee6cf8d0a0520794034d605c45a30cad
pi@SPRINT:~ $
output pdf generates 0 byte files, other formats work.
After scanning Text with 300dpi and no colour the PDF (one page) is aorund 10-13 MB big. It's possible to minify the with ghostscript (ps2pdf big.pdf small.pdf) to about 0,3 MB.
This is a pretty minor issue, but slightly annoying because the preview and scan buttons do not work until I select a color. I think that clicking reset should default colour back to the first item in the list instead of clearing it. When I first open the webpage, I have three color options (lineart, gray, and color) and lineart is selected.
Consider:
Moving shell scripts to /bin
Moving install / images etc into /docs
Some options are marked as [inactive]
in the output of scanimage -A
. For my scanner that is for example --brightness
.
The SANE API Documentations (http://www.sane-project.org/html/doc011.html#s4.2.9.7) says
SANE_CAP_INACTIVE | 32 | If set, this capability indicates that the option is not currently active (e.g., because it's meaningful only if another option is set to some other value).
but leaves it unclear when an inactive option may be set and when it should not.
scanimage
on the other hand seems to fail when an inactive option is set. (See https://gitlab.com/sane-project/backends/-/blob/master/frontend/scanimage.c#L1046)
Therefore I am not sure if there is any way to make it work with an inactive option (by e.g. setting other options first).
In order for it to work on all devices, we need to either read all available options from scanimage -A
and filter out inactive options, give the user a way to disable options, or test if any of the "default" options are inactive (as an addition to testing if they are available which is already done here https://github.com/sbs20/scanservjs/blob/master/client/components/Scanserv.vue#L407).
In my opinion, the first way would be best, as we cannot really assume that there is a set of "default" options.
There are so called "Well-Known Options" (see http://www.sane-project.org/html/doc014.html), but they do not include --brightness
and --contrast
which therefore don't have any fixed meaning we can rely on.
Sometimes scanimage -L
doesn't return anything (see #85). In those cases, running it just slows everything down. Support ignoring the listing
Describe the bug
When i try to start scanning with my pixma mx 395 device i get for the -l -t -x -y NAN
/usr/bin/scanimage -d 'pixma:04A91766_004AE4' --mode 'Color' --resolution 100 -l NaN -t NaN -x NaN -y NaN --format 'tiff' --source 'Flatbed' > ./data/temp/~tmp-scan-0001.tif
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Scanner should scan the page.
Client (please complete the following information):
Server (please complete the following information):
Congrats for making this tool :) It's really useful!
I'd like to ask you a new feature: when scanning documents it's really useful to have them as pdf.
With imagemagick's convert tool it should be quite easy to configure the output to pdf
SInce I updated my sbs20/scanservjs:latest docker image to 2.0.2, scanservjs stopped working. Neither preview nor scan works. Error message:
/usr/bin/scanimage -d "net:192.168.1.4:xerox_mfp:libusb:001:003" --mode "color" --resolution 100 -l nan -t nan -x nan -y nan --format "tiff" > ./data/preview/preview.tif exited with code: 4, stderr: scanimage: rounded value of tl-x from -32768 to -32768 scanimage: rounded value of tl-y from -32768 to -32768 scanimage: rounded value of br-x from -32768 to -32768 scanimage: rounded value of br-y from -32768 to -32768 scanimage: sane_start: invalid argument
Saned is running on an OpenWRT 19.07.3 router, to which my Samsung SCX3200 MFP is connected to.
Hi,
I just updated my very old scanserv-js (1.0.1) to the newest version.
now I get this error in the gui "Incorrect value of args option".
When I press preview or print in GUI I get the error message.
But I can run the preview command from terminal successfully:
/usr/bin/scanimage -d "epson2:libusb:001:004" --mode "Gray" --resolution 100 -l 0 -t 0 -x 215 -y 297 --format "tiff" --brightness 0 > preview.tif
This is from journalctl:
[2020-09-21T14:07:03.179Z] ERROR (global): TypeError: Incorrect value of args option
Sep 21 16:07:03 scan Server.js[27726]: at normalizeSpawnArguments (child_process.js:389:11)
Sep 21 16:07:03 scan Server.js[27726]: at exports.spawn (child_process.js:496:38)
Sep 21 16:07:03 scan Server.js[27726]: at Promise (/var/www/scanservjs/server/Process.js:23:20)
Sep 21 16:07:03 scan Server.js[27726]: at new Promise ()
Sep 21 16:07:03 scan Server.js[27726]: at Object.spawn (/var/www/scanservjs/server/Process.js:20:18)
Sep 21 16:07:03 scan Server.js[27726]: at Function.createPreview (/var/www/scanservjs/server/Api.js:57:19)
Sep 21 16:07:03 scan Server.js[27726]: at <anonymous>
Sep 21 16:07:03 scan Server.js[27726]: at process._tickCallback (internal/process/next_tick.js:188:7)
Thanks
I got this working in a docker container running ubuntu and passing my brother MFC-7320 through to docker.
This works perfectly in grey, but fails in mode color.
I confirmed by hacking your Scanimage class, when you add the mode onto the cmd line, you pass Color, no quotes, passing "24bit Color" (with quotes) works fine for me.
Any way you can give us the option to setup ? Or autodetect ?
I'm using following scanimage version : scanimage (sane-backends) 1.0.27; backend version 1.0.27
I didn't just invent "24bitColor", it showed in the help of scanimage (scanimage -h)
When using development
branch, clicking "preview" does not produce image preview in, well, preview area.
It works just fine with the master branch.
Also, during any scanning, console gets full of ERROR 500
's.
It would be awesome to have a scanned file not only come out as a jpg (see enhancement request #12 )
But also have the option for pdf with ocr format.
I can help with that, I already have the one-liner bash that calls tesseract with a jpg input, and spits out a pdf file with the jpg in front and the OCR text behind the image ==> Very useful to be able to index documents since crawlers will see the OCR text, and humans when they open the pdf will still only see the fully correct jpg file in foreground...
Some scanners do not support certain features (e.g. brightness / contrast - see results of scanimage -A
). Scanservjs now ignores these features so that it at least works.
It would be good to hide unsupported features in the UI too.
Sam,
may I ask you to make the available buttons and sliders dependend on the output of scanimage -A
?
For example:
[scanservjs@scanprint ~]$ /usr/bin/scanimage -A
All options specific to device epson2:libusb:001:006:
Scan Mode:
--mode Lineart|Gray|Color [Lineart]
Selects the scan mode (e.g., lineart, monochrome, or color).
[...]
--brightness 0..0 [inactive]
Selects the brightness.
--sharpness -2..2 [inactive]
Otherwise the command will fail with something like:
scanimage: attempted to set inactive option brightness
Thanks,
Andy
Sometimes scanimage -L
doesn't return a scanner - this is more likely with net hosts (those added /etc/sane.d/net.conf
), especially if you're chaining to a host which is using airscan. Support a fixed definition of scanner devices.
The install.sh
script chmods the old location of server.js
(/var/www/scanservjs/server.js
). It should be /var/www/scanservjs/server/Server.js
.
This line https://github.com/sbs20/scanservjs/blob/master/install.sh#L65 should read
chmod +x $scansrvjs_home/server/Server.js
instead of
chmod +x $scansrvjs_home/server.js
P.S.: That new version looks truly amazing and that pipeline concept will probably make it very easy to include new formats and post-processing.
Enable multi-page scanning through user prompts in the UI
See #48
Your installer script is very nice and does work even for me inside a docker container.
But it still complains that the container hass no init.d subsystem, it tries to start the service after installing it...
If I get around to it I'll probably make a PR to add an optional argument to have the installer "container-friendly" or at least "silent install".
Hi,
Is that possible to create an option to print the document scanned in a printer ?
The printer can be by exemple included in a server like cups.
Thanks !
First: thank you for the great work! I love that project.
But I can't scan to PDF getting the error below:
command failed: /usr/bin/scanimage -d "genesys:libusb:003:002" --mode "color" --resolution 300 -l 0 -t 0 -x 210 -y 297 --format tiff --brightness 0 --contrast 0 | convert - pdf:- > "./data/output/scan_2020-08-27 18.01.18.pdf" convert-im6.q16: attempt to perform an operation not allowed by the security policy `pdf' @ error/constitute.c/iscoderauthorized/408.
I do not really understand that error. Is it a problem "inside" or "itside" of the container?
According to the (scanimage docs)[https://linux.die.net/man/1/scanimage] there is a black-and-white
format.
I believe this will mirror the black and white mode in my devices Windows software, but I am unable to select this from the UI. Is this trivial to add?
There's no such thing as a multipage JPG or PNG. Need to output a list of filenames or disable those pipelines
Hi,
When I click on the "scan" button or on the "preview" button and when the USB scanner is not plugged (usb) or is off, the scanservjs returns an error (message in red font) :
Command failed: /usr/bin/scanimage -d "epson2:libusb:001:004" --mode "Color" --resolution 300 -l 0 -t 0 -x 215 -y 297 --format tiff | convert - jpg:- > "./data/output/scan_2020-07-03 16.46.03.jpg" scanimage: open of device epson2:libusb:001:004 failed: Invalid argument convert-im6.q16: no decode delegate for this image format ' @ error/constitute.c/ReadImage/560. convert-im6.q16: no images defined
jpg:-' @ error/convert.c/ConvertImageCommand/3258.
And then it is impossible to scan another time, even tough I plug the scanner. If I plug the scanner after, the command scanimage -L returns something like :
device `epson2:libusb:001:004' is a Epson PID 08C8 flatbed scanner
If I want to scan again, I have to make a new install of scanerservjs :
wget -O ~/scanservjs.tar.gz $(curl -s https://api.github.com/repos/sbs20/scanservjs/releases/latest | grep browser_download_url | cut -d '"' -f 4)
tar -xf scanservjs.tar.gz
sudo ./scanservjs/install.sh
rm scanservjs.tar.gz
rm -r scanservjs
When we click on "scan" or "preview", Is that possible that the command :
scanimage -L returns something ?
Tried to install scanservjs on a Raspi running Debian jessi light.
./install.sh will fail with
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli '--only=production' ]
2 info using [email protected]
3 info using [email protected]
4 error install Couldn't read dependencies
5 error Error: Invalid name: "@sbs20/scanservjs"
5 error at ensureValidName (/usr/lib/nodejs/normalize-package-data/lib/fixer.js:284:15)
Changed name in package.json to
{ "name": "scanservjs",
to complete installation.
Jan 13 09:20:12 printscan server.js[4655]: /var/www/scanservjs/classes/Config.js:14
Jan 13 09:20:12 printscan server.js[4655]: SupportsDepth: false;
Jan 13 09:20:12 printscan server.js[4655]: ^
Jan 13 09:20:12 printscan server.js[4655]: SyntaxError: Unexpected token ;
Changed the ;
into ,
in /var/www/scanservjs/classes/Config.js
Jan 13 09:30:08 printscan server.js[4978]: /var/www/scanservjs/classes/System.js:27
Jan 13 09:30:08 printscan server.js[4978]: execute(cmd) {
Jan 13 09:30:08 printscan server.js[4978]: ^
Jan 13 09:30:08 printscan server.js[4978]: SyntaxError: Unexpected token (
Changed in /var/www/scanservjs/classes/System.js
to
execute: function(cmd) {
The webserver starts w/o errors, but the UI is missing. You'll see:
scanserv.js
Command line testing »
Input Box with button "exec" right next to it
Anything else missing or needs to be changed?
Device:
device `genesys:libusb:001:017' is a Canon LiDE 120 flatbed scanner
I am able to successfully run a preview, but when I run a scan, the scanner seems to be scanning, then just when it sounds like it is finished I get:
ERROR (Http): Error: convert @- -quality 92 scan-%04d.jpg exited with code: 1, stderr: convert-im6.q16: cache resources exhausted `~tmp-scan-0001.tif' @ error/cache.c/OpenPixelCache/4083.
convert-im6.q16: no images defined `scan-%04d.jpg' @ error/convert.c/ConvertImageCommand/3258.
at ChildProcess.<anonymous> (/app/server/process.js:44:18)
at ChildProcess.emit (node:events:327:20)
at maybeClose (node:internal/child_process:1048:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.