Skip to main content

wia_scan 0.7.0

Project description

wia_scan

wia_scan

wia_scan on PyPI wia_scan PyPI License Coverage Status

A simple utility for using document scanners that support Windows Image Acquisition (WIA) and is easy to install. If your scanner works using Windows Fax and Scan, there is a good chance it will work with this python script. This package allows you to create your own efficient scanning loop or use the one the one already provided.

Use cases:

  • You have a flatbed scanner, and you need to scan a lot of documents, thus you don't want to use Windows Fax and Scan tool as it can introduce quite some overhead. This utility allows you to only press a few keystrokes in between scans, while you may need to turn the page or change the paper since you don't have an automatic feeding scanner like I don't.
  • Support scanners in your own application on Windows using a simple Python dependency

The utility supports a simple calibration process which is fully visual. The reason for this process is that my scanner's default brightness (corresponding to brightness=0) is too bright.

Alternatives: Existing WIA libraries, but to my surprise the ones I found required quite old versions of Python, which I didn't want since I wanted to combine the scanning process with some modern Python packages.

Installation

pip install wia_scan

Alternative: From Source

Download this source and install flit using pip install flit and run the following command from the source folder

flit install

Usage

Scan Many Documents

The main use case of this utility is to scan many documents using a few key presses, this can be achieved by running

wia_scan many

During the process, the utility will ask you beforehand which quality profile should be used for the next scan, and multiple sides can be combined into a single picture.

Command Line Interface

  wia_scan list_devices [-v]
  wia_scan single [--file=<output_file>] [--dpi=<dpi>] [--brightness=<brightness>]
                  [--contrast=<contrast>] [--mode=<mode>] [-v] [--uid=<uid>] [-q]
  wia_scan many [--out=<output_folder>] [-v]
  wia_scan calibrate brightness [--start=<start_range>] [--end=<end_range>]
                [--num_runs=<num_runs>] [--out=<output_folder>] [--uid=<uid>] [-q]
  wia_scan --help
  wia_scan --version

Options:
  -h --help                    Show this screen.
  --version                    Show version.
  -v --verbose                 Verbose output
  -q --quiet                   Quiet=no output
  --dpi=<dpi>                  Dots per inch; the higher this setting the higher the
                               output resolution [default: 200]
  --brightness=<brightness>    Brightness setting for the scanner, goes from -1000 to 1000
                               [default: 0]
  --contrast=<contrast>        Contrast setting for the scanner, goes from -1000 to 1000
                               [default: 0]
  --mode=<mode>                RGB for colored, L for grayscale [default: RGB]
  --file=<output_file>         Image output file
  --out=<output_folder>        Directory which the files are written to [default: .]
  --start=<start_range>        Lowest value of brightness scanned [default: -200]
  --end=<end_range>            Highest value of brightness scanned [default: 200]
  --num_runs=<num_runs>        Number of scans for the "calibration" process [default: 9]

Library Usage - Custom Loop

Example: Create your own python file custom_loop.py and scan many single sided documents from the same scanner while waiting for a single key press between scans:

from wia_scan import *

device = prompt_choose_device_and_connect()
for i in range(1000000):
    press_any_key_to_continue()
    pillow_image = scan_side(device=device, scan_profile=DEFAULT_SCAN_PROFILE)
    filename = f'{i}.jpeg'
    pillow_image.save(filename, subsampling=0, optimize=True,
             progressive=True, quality=80)

License

wia_scan is distributed under the terms of the MIT license.

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

wia_scan-0.7.0.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

wia_scan-0.7.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file wia_scan-0.7.0.tar.gz.

File metadata

  • Download URL: wia_scan-0.7.0.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for wia_scan-0.7.0.tar.gz
Algorithm Hash digest
SHA256 c6942464ab77d9bca3260430677274905d88d7309248936103880e2e14b3924e
MD5 6e3b6a267ab28a555bf0ebeaee0baf12
BLAKE2b-256 64c695cb4e7c1f078f282f8f20c946b68af54680dd6d078cee644d31b08dc444

See more details on using hashes here.

File details

Details for the file wia_scan-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: wia_scan-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for wia_scan-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5971b9eafd4c38f6381ac4a883b5ed171e6451814d475605378b2945b9934eb
MD5 73bfac273e7eb36c5e27f07ce3f74967
BLAKE2b-256 6d7cac3a3edc4d6dd5b3e03218dd03581f69e52475322095462c863867a72096

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page