python-pillow / Sane

Python interface to the SANE scanner and frame grabber
Other
55 stars 19 forks source link

HP All-in-one: ADF feeds two sheets when one is canned #73

Open blake5634 opened 3 years ago

blake5634 commented 3 years ago

If I e.g. use the iterator to scan 3 pages, a 4th one is also fed. Below is a minimal example which scans one page but feeds two sheets.

#!/usr/bin/env python
import sane
import numpy
from PIL import Image
#
# Initialize sane
#
ver = sane.init()
print('SANE version:', ver)
# prints: SANE version: (16777245, 1, 0, 29)
#
# Get devices
#
#devices = sane.get_devices()
#print('Available devices:', devices)      
sc_dev = ('hpaio:/net/hp_officejet_pro_9020_series?ip=192.168.0.57&queue=false', 'Hewlett-Packard', 'hp_officejet_pro_9020_series', 'all-in-one')

print('\n Opening: \n', sc_dev[1], sc_dev[2])
#
# Open first device
#
dev = sane.open(sc_dev[0])

try:
  dev.depth = 8
  dev.mode = 'Color'
  dev.source = 'ADF'
  dev.resolution = 200
except:
  print('problem setting params')
  quit()
#
# Start a scan and get a PIL.Image object
#
dev.start()
im = dev.snap()
im.save('test_pil.png') 
#
# Close the device
#
dev.close()
manisandro commented 3 years ago

Generally with these types of issues, it's hard to debug them without having an affected device. You'll need to do some in-depth debugging on your side to narrow down the issue and ideally file a PR with a fix.

blake5634 commented 3 years ago

Well, my interim solution is to only load the pages I wish to scan. "ADF out of documents" detection works fine. Sorry, I use sane for work and don't have time to debug further than the minimal code example above. But it would be able to load for example a stack of 10 2-page documents. I do appreciate your work on sane!