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

Scan returns "Scan complete" but only empty files #20

Open
didnt1able opened this issue Nov 13, 2019 · 15 comments
Open

Scan returns "Scan complete" but only empty files #20

didnt1able opened this issue Nov 13, 2019 · 15 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@didnt1able
Copy link

didnt1able commented Nov 13, 2019

Doing sudo -u www-data scanimage >test.jpeg returns a good scan for the webserver user. When scanning in nextcloud it just drops empty files

nextcloud version 17.0.1.1
jQpkd75BEg

@e-alfred
Copy link
Owner

Did you install al dependencies? Pnmtojepg/netpbm is a requirement for the scan app to work.

Please add more information about your environment to make debugging your problem easier.

@didnt1able
Copy link
Author

didnt1able commented Nov 14, 2019

Yes all dependencies are present

Im running nginx with php7.2-fpm postgresql for database. Is there anywhere where i can view the log specific to scanner. Nothing shows up in the error log because its not considered an error.

{
    "id": "oc74392ggqjl",
    "items": [
        [
            "server",
            "version",
            "17.0.1.1"
        ],
        [
            "server",
            "code",
            "other"
        ],
        [
            "server",
            "enable_avatars",
            "yes"
        ],
        [
            "server",
            "enable_previews",
            "yes"
        ],
        [
            "server",
            "memcache.local",
            "\\OC\\Memcache\\APCu"
        ],
        [
            "server",
            "memcache.distributed",
            "\\OC\\Memcache\\Redis"
        ],
        [
            "server",
            "asset-pipeline.enabled",
            "no"
        ],
        [
            "server",
            "filelocking.enabled",
            "yes"
        ],
        [
            "server",
            "memcache.locking",
            "\\OC\\Memcache\\Redis"
        ],
        [
            "server",
            "debug",
            "no"
        ],
        [
            "server",
            "cron",
            "cron"
        ],
        [
            "php",
            "version",
            "7.2.24"
        ],
        [
            "php",
            "memory_limit",
            5242880000
        ],
        [
            "php",
            "max_execution_time",
            3600
        ],
        [
            "php",
            "upload_max_filesize",
            10737418240
        ],
        [
            "database",
            "type",
            "pgsql"
        ],
        [
            "database",
            "version",
            "PostgreSQL 11.5 (Ubuntu 11.5-3.pgdg18.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit"
        ],
        [
            "database",
            "size",
            17822367
        ],
        [
            "files_sharing",
            "num_shares",
            0
        ],
        [
            "files_sharing",
            "num_shares_user",
            0
        ],
        [
            "files_sharing",
            "num_shares_groups",
            0
        ],
        [
            "files_sharing",
            "num_shares_link",
            0
        ],
        [
            "files_sharing",
            "num_shares_link_no_password",
            0
        ],
        [
            "files_sharing",
            "num_fed_shares_sent",
            0
        ],
        [
            "files_sharing",
            "num_fed_shares_received",
            0
        ],
        [
            "encryption",
            "enabled",
            "yes"
        ]
    ]
dpkg -l | grep netpbm
ii  libnetpbm10                            2:10.0-15.3build1                               amd64        Graphics conversion tools shared libraries
ii  netpbm                                 2:10.0-15.3build1                               amd64        Graphics conversion tools between image formats
sudo -u www-data scanimage -T
scanimage: rounded value of br-x from 215.9 to 215.88
scanimage: rounded value of br-y from 355.6 to 355.567
scanimage: scanning image of size 1648x2291 pixels at 24 bits/pixel
scanimage: acquiring RGB frame, 8 bits/sample
scanimage: reading one scanline, 4944 bytes...	PASS
scanimage: reading one byte...		PASS
scanimage: stepped read, 2 bytes... 	PASS
scanimage: stepped read, 4 bytes... 	PASS
scanimage: stepped read, 8 bytes... 	PASS
scanimage: stepped read, 16 bytes... 	PASS
scanimage: stepped read, 32 bytes... 	PASS
scanimage: stepped read, 64 bytes... 	PASS
scanimage: stepped read, 128 bytes... 	PASS
scanimage: stepped read, 256 bytes... 	PASS
scanimage: stepped read, 512 bytes... 	PASS
scanimage: stepped read, 1024 bytes... 	PASS
scanimage: stepped read, 2048 bytes... 	PASS
scanimage: stepped read, 4096 bytes... 	PASS
scanimage: stepped read, 8192 bytes... 	PASS
scanimage: stepped read, 8191 bytes... 	PASS
scanimage: stepped read, 4095 bytes... 	PASS
scanimage: stepped read, 2047 bytes... 	PASS
scanimage: stepped read, 1023 bytes... 	PASS
scanimage: stepped read, 511 bytes... 	PASS
scanimage: stepped read, 255 bytes... 	PASS
scanimage: stepped read, 127 bytes... 	PASS
scanimage: stepped read, 63 bytes... 	PASS
scanimage: stepped read, 31 bytes... 	PASS
scanimage: stepped read, 15 bytes... 	PASS
scanimage: stepped read, 7 bytes... 	PASS
scanimage: stepped read, 3 bytes... 	PASS

@e-alfred
Copy link
Owner

Did you add the following line using visudo:

www-data ALL = (root) NOPASSWD: /usr/bin/scanimage

The command doing the scan should look like this:

image

What type of scanner/SANE backend do you use?

@e-alfred e-alfred added the help wanted Extra attention is needed label Nov 25, 2019
@didnt1able
Copy link
Author

didnt1able commented Nov 28, 2019

Did you add the following line using visudo:

www-data ALL = (root) NOPASSWD: /usr/bin/scanimage

www-data has print and scan permissions

Connection is over handled with ipp
ipp://192.168.0.x.x/ipp

Scanning via terminal under www-data returns scans

sane:
  Installed: 1.0.14-12build1
  Candidate: 1.0.14-12build1

Scanner is Brother MFC-9130CW

scanimage -L
device `brother4:net1;dev0' is a Brother MFC-9130CW MFC-9130CW
device `net:localhost:brother4:net1;dev0' is a Brother MFC-9130CW MFC-9130CW

Also sudo scanimage --device=brother4 returns Segmentation fault not sure what that is about

@e-alfred
Copy link
Owner

e-alfred commented Nov 29, 2019

Okay, but can you execute the following commands:

scanimage --help This should output all the options your Brother scanner supports.
sudo -u www-data scanimage --mode color --resolution 300 -x 215 -y 217 To see if a scan with the default options used by this app works.

Also, the segmentation fault might be related to this problem: https://www.linuxquestions.org/questions/slackware-14/xsane-and-scanimage-segfaulting-4175550933/

@didnt1able
Copy link
Author

sudo -u www-data scanimage --mode color --resolution 300 -x 215 -y 217 returns scanimage: setting of option --mode failed (Invalid argument)

scanimage --help
Usage: scanimage [OPTION]...

Start image acquisition on a scanner device and write image data to
standard output.

Parameters are separated by a blank from single-character options (e.g.
-d epson) and by a "=" from multi-character options (e.g. --device-name=epson).
-d, --device-name=DEVICE   use a given scanner device (e.g. hp:/dev/scanner)
    --format=pnm|tiff|png|jpeg  file format of output file
-i, --icc-profile=PROFILE  include this ICC profile into TIFF file
-L, --list-devices         show available scanner devices
-f, --formatted-device-list=FORMAT similar to -L, but the FORMAT of the output
                           can be specified: %d (device name), %v (vendor),
                           %m (model), %t (type), %i (index number), and
                           %n (newline)
-b, --batch[=FORMAT]       working in batch mode, FORMAT is `out%d.pnm' `out%d.tif'
                           `out%d.png' or `out%d.jpg' by default depending on --format
    --batch-start=#        page number to start naming files with
    --batch-count=#        how many pages to scan in batch mode
    --batch-increment=#    increase page number in filename by #
    --batch-double         increment page number by two, same as
                           --batch-increment=2
    --batch-print          print image filenames to stdout
    --batch-prompt         ask for pressing a key before scanning a page
    --accept-md5-only      only accept authorization requests using md5
-p, --progress             print progress messages
-n, --dont-scan            only set options, don't actually scan
-T, --test                 test backend thoroughly
-A, --all-options          list all available backend options
-h, --help                 display this help message and exit
-v, --verbose              give even more status messages
-B, --buffer-size=#        change input buffer size (in kB, default 32)
-V, --version              print version information
scanimage: rounded value of br-x from 215.9 to 215.88
scanimage: rounded value of br-y from 355.6 to 355.567

Options specific to device `brother4:net1;dev0':
  Mode:
    --mode Black & White|Gray[Error Diffusion]|True Gray|24bit Color|24bit Color[Fast] [24bit Color[Fast]]
        Select the scan mode
    --resolution 100|150|200|300|400|600|1200|2400|4800|9600dpi [200]
        Sets the resolution of the scanned image.
    --source FlatBed|Automatic Document Feeder(left aligned)|Automatic Document Feeder(centrally aligned) [Automatic Document Feeder(left aligned)]
        Selects the scan source (such as a document-feeder).
    --brightness -50..50% (in steps of 1) [inactive]
        Controls the brightness of the acquired image.
    --contrast -50..50% (in steps of 1) [inactive]
        Controls the contrast of the acquired image.
  Geometry:
    -l 0..215.9mm (in steps of 0.0999908) [0]
        Top-left x position of scan area.
    -t 0..355.6mm (in steps of 0.0999908) [0]
        Top-left y position of scan area.
    -x 0..215.9mm (in steps of 0.0999908) [215.88]
        Width of scan-area.
    -y 0..355.6mm (in steps of 0.0999908) [355.567]
        Height of scan-area.

@e-alfred e-alfred added the bug Something isn't working label Nov 30, 2019
@e-alfred
Copy link
Owner

e-alfred commented Nov 30, 2019

The problem is that the Brother scanner backend for SANE obviously uses different terminology for the "mode" setting (in this case "24bit Color" instead of "color"). This will probably be fixed with https://github.com/e-alfred/nextcloud-scanner/tree/vuejs-rework by @Biont, I hope he can work on this again.

@didnt1able
Copy link
Author

Thank you for your help, its greatly appreciated.

@noci2012
Copy link

noci2012 commented Dec 23, 2019

I see these in the logfiles: ( same result: 0 sized image files, running by hand does work though).
imagecreatefromstring(): Data is not in a recognized format at ............/lib/private/legacy/image.php#622

probably due to this:
-rw-r--r-- 1 nginx nginx 0 Dec 23 14:34 /tmp/img

scanimage & pnmtojepg are both in /usr/bin which in the path.
and can be used by the account that runs the web stuff.

@peterneutron
Copy link

peterneutron commented Apr 24, 2020

Having a weird issue at the moment with Scanner 1.8.0 and Nextcloud 18.0.4. When I'm trying to scan from the web interface it creates an empty file, but running

sudo -u http scanimage --mode color --resolution 300 -x 215 -y 297| pnmtojpeg > /tmp/img

from the command line works as expected. Also when triggering the scan from the web interface the /tmp/img files does not get created. According to the php-fqm log the command is triggered.

sudo[1316296]: http : TTY=unknown ; PWD=/usr/share/webapps/nextcloud ; USER=root ; COMMAND=/usr/bin/scanimage --mode Color --resolution 300 -x 215 -y 297
sudo[1316296]: pam_unix(sudo:session): session opened for user root by (uid=0)

Edit

Fixed the issue by setting PrivateDevices=false in my systemd php-fqm.service file.

@cNULLjack
Copy link

There is another way to fix the issue without the need of www-data ALL = (root) NOPASSWD: /usr/bin/scanimage (what I think was the problem and should also solve the issue)
After Adding www-data to the lp group (to grant usb permission) there is no need to run the scanimage command as root. Therefor you must delete the leading "sudo" from the scanimage-command in the file /lib/Storage/ScannerStorage.php (current version line 60).

@schmidtbag
Copy link

schmidtbag commented Jul 26, 2020

If anyone else is still having problems, look up the udev rules in the Arch Linux wiki; that applies to all distros, not just Arch (I'm using Debian myself).
Also, it is worth trying to do:
gpasswd -a www-data scanner
Might or might not help, but it certainly won't hurt.

@amo13
Copy link

amo13 commented Aug 19, 2020

For me,
sudo -u www-data scanimage --mode color --resolution 300 -x 215 -y 217
returns
scanimage: setting of option --mode failed (Invalid argument)

so i guess the issue is the same with the mode flag that is not understood by my samsung scanner. no problem with sudo since the scanner is recognized from the network (not usb) automatically.

@StevenDeRoover
Copy link

Is there any update on this?

I have the same issue, and cannot get it resolved.

@akang-donai
Copy link

Í am using dedicated Brother Scanner, ADS-3000N and connected thru' network. Based on you guys chatter around, so I modified in here, change accordingly to what @didnt1able share about brother help command into this one, "sudo scanimage --mode '24bit Color[Fast]' --resolution {$resolution} -x 215 -y 297| pnmtojpeg > /tmp/img",

Now its working from WebUI of Nextcloud, so, I need learn the code so maybe just a suggestion, you need a scanner BRAND Model database, since its model the scan command line to execute are different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants