TWAIN API for accessing scanners, cameras, etc on Windows
Project description
pytwain
This library allows acquiring images from various sources that support TWAIN protocol, e.g. scanners.
To install this library run:
pip install pytwain
Once installed you can run following sample Python script to acquire an image:
import twain
import tkinter
import logging
logging.basicConfig(level=logging.DEBUG)
root = tkinter.Tk()
root.title('scan.py')
with twain.SourceManager(root) as sm:
# this will show UI to allow user to select source
src = sm.open_source()
if src:
src.request_acquire(show_ui=False, modal_ui=False)
(handle, remaining_count) = src.xfer_image_natively()
twain.dib_to_bm_file(handle, 'testscan.bmp')
else:
print("User clicked cancel")
Full documentation for the library located here.
This library uses ctypes to access TWAIN API, therefore it does not require compilation and can work with Pypi.
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytwain-2.2.1.tar.gz
(26.6 kB
view hashes)