sbs20 / scanservjs

SANE scanner nodejs web ui
https://sbs20.github.io/scanservjs/
GNU General Public License v2.0
686 stars 137 forks source link

Convert failed - convert: Bogus "StripByteCounts" field #704

Open keatre opened 7 months ago

keatre commented 7 months ago

Describe the bug When issuing a scan from the WebGUI - the scanner is found, and I scan the image - but the system errors out on the convert command.

[2023-12-03T21:54:36.568Z] INFO (ScanController): Scanning
Dec 03 15:54:36 vmhdd server.js[842]: [2023-12-03T21:54:36.569Z] INFO (Process): { spawn:
Dec 03 15:54:36 vmhdd server.js[842]:    '/usr/bin/scanimage -d net:192.168.4.125:epsonds:libusb:001:004 --source \'ADF Duplex\' --mode Color --resolution 400 -l 0 -t 0 -x 215.9 -y 393.7 --format tiff -o data/temp/~tmp-scan-0-0001.tif' }
Dec 03 15:54:50 vmhdd server.js[842]: [2023-12-03T21:54:50.641Z] INFO (Process): { spawn:
Dec 03 15:54:50 vmhdd server.js[842]:    '/usr/bin/convert data/temp/~tmp-scan-0-0001.tif -scale 868 -background \'#808080\' -extent 868x1583-0-0 data/preview/preview.tif' }
Dec 03 15:54:50 vmhdd server.js[842]: [2023-12-03T21:54:50.770Z] ERROR (Http): Error: /usr/bin/convert data/temp/~tmp-scan-0-0001.tif -scale 868 -background '#808080' -extent 868x1583-0-0 data/preview/preview.tif exited with code: 1, stderr: convert: Bogus "StripByteCounts" field, ignoring and calculating from imagelength. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/949.
Dec 03 15:54:50 vmhdd server.js[842]: convert: insufficient image data in file `data/temp/~tmp-scan-0-0001.tif' @ error/tiff.c/ReadTIFFImage/1671.
Dec 03 15:54:50 vmhdd server.js[842]: convert: no images defined `data/preview/preview.tif' @ error/convert.c/ConvertImageCommand/3258.
Dec 03 15:54:50 vmhdd server.js[842]:     at ChildProcess.proc.on (/usr/lib/scanservjs/server/classes/process.js:85:18)
Dec 03 15:54:50 vmhdd server.js[842]:     at ChildProcess.emit (events.js:198:13)
Dec 03 15:54:50 vmhdd server.js[842]:     at maybeClose (internal/child_process.js:982:16)
Dec 03 15:54:50 vmhdd server.js[842]:     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

To Reproduce I can call 'convert' manually using the same parameters to the TIFF file, and it errors out as well:

keatre@vmhdd:/usr/lib/scanservjs$ /usr/bin/convert data/temp/~tmp-scan-0-0001.tif -scale 868 -background '#808080' -extent 868x1583-0-0 data/preview/preview.tif
convert: Bogus "StripByteCounts" field, ignoring and calculating from imagelength. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/949.
convert: insufficient image data in file `data/temp/~tmp-scan-0-0001.tif' @ error/tiff.c/ReadTIFFImage/1671.
convert: no images defined `data/preview/preview.tif' @ error/convert.c/ConvertImageCommand/3258.

Client (please complete the following information):

Server (please complete the following information):

keatre@vmhdd:/$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Additional context Scanner: Epson FF-680W -> USB to SANE Server SANE Server: Raspberry Pi 3b+ Scanservjs machine: VM Ubuntu 20.04

mauveferret commented 2 months ago

@keatre, your error is similar to mentioned in #406 and #445. In these issues the bogus StripByteCounts tag of the TIFF files is causes the same output error as yours during convert procedure. In the mentioned issues the problem was associated with the bad HP driver, that corrupts TIFFs (and some other file formats too). So, probably, something similar happens due to your Epson FF-680W. One of the suggested ways was to suppress the convert errors (1,2).

You can try the commands like sudo su --shell /bin/bash - scanservjs --command 'scanimage --mode Color -x 215.9 -y 299.7 --format png --resolution 300 > test.png sudo su --shell /bin/bash - scanservjs --command 'scanimage --mode Color -x 215.9 -y 299.7 --format tiff --resolution 300 > test.tiff to check whether your problem is only with tiff format or not.