scanimage producing invalid image files

Asked by David Gersic on 2019-04-14

dgersic@farfalla:~> scanimage -L
device `hpaio:/usb/HP_OfficeJet_Pro_8710?serial=CN8CBDT2CW' is a
Hewlett-Packard HP_OfficeJet_Pro_8710 all-in-one

dgersic@farfalla:~> scanimage -T
scanimage: scanning image of size 637x877 pixels at 1
bits/pixel scanimage: acquiring gray frame, 1 bits/sample
scanimage: reading one scanline, 80 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, 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

dgersic@farfalla:~> scanimage -V
scanimage (sane-backends) 1.0.27; backend version 1.0.27

If I scan a page with:

scanimage --format=pnm --mode Color --source ADF --resolution 300 -l 0
-t 0 -x 215.9 -y 279.5

The resuling pnm file seems to be corrupt. Neither ImageMatick convert
nor Gnome's viewer is happy with the file. Gimp will import it, and can
re-save it as a working pnm file (same for PNG and JPG), which then
convert is happy with.

I can provide examples of "bad" and "good" files if that would help.

Question information

Language:
English Edit question
Status:
Open
For:
HPLIP Edit question
Assignee:
No assignee Edit question
Last query:
2019-04-16
Last reply:

Was using hplip 3.18. Downloaded and installed 3.19.3 and no change.

convert: unable to read image data `page1.pnm' @ error/pnm.c/ReadPNMImage/1346.

I dumped a sample pnm file to hex:

00000000 50 36 0a 23 20 53 41 4e 45 20 64 61 74 61 20 66 |P6.# SANE data f|
00000010 6f 6c 6c 6f 77 73 0a 32 35 35 30 20 33 33 30 31 |ollows.2550 3301|
00000020 0a 32 35 35 0a e8 f2 f4 e8 f2 f4 e8 f2 f4 e8 f2 |.255............|

and did some poking around. The math on the file size here (2550 x 3301) doesn't work. There isn't enough data in the file for this. If I take actual file size, divide by 2550, I get 3296. So I hex edited the file to:

00000000 50 36 0a 23 20 53 41 4e 45 20 64 61 74 61 20 66 |P6.# SANE data f|
00000010 6f 6c 6c 6f 77 73 0a 32 35 35 30 20 33 32 39 36 |ollows.2550 3296|
00000020 0a 32 35 35 0a e8 f2 f4 e8 f2 f4 e8 f2 f4 e8 f2 |.255............|

and now convert works fine with it.

Concluding that either there's data missing from the end of the file, or the header is wrong.

Further testing with scanned pages seems to show that all of the data is there, it's the header that is wrong.

Can you help with this problem?

Provide an answer of your own, or ask David Gersic for more information if necessary.

To post a message you must log in.