Pyinsane 是 Sane API (使用ctypes) 和抽象层的纯 Python 实现。支持 Python 2.7 和 3.x,要求 Pillow 和 libsane 支持。
实现简单扫描的代码:
device.options['resolution'].value = 300 # Beware: Some scanner have "Lineart" or "Gray" as default mode device.options['mode'].value = 'Color' scan_instance = device.scan(multiple=False) try: while True: scan_instance.read() except EOFError: pass image = scan_instance.get_img()