Skip to main content

An combination of Twain and SANE API

Project description

An combination of Twain and SANE API

Requirements:

  • Python 2.*

  • SANE API for Linux

  • Twain Lib for Win32

Functions:

  • pyScanLib() - Main Class

  • getScanners() - Return Scanner with Name

  • setScanners(scannerName)

  • setDPI(dpi)

  • setScanArea(left,top,width,height) - For scanning selected Area size in Inches

  • setPixelType(“color”) - bw (Black & White), gray and color

  • scan() - Start Scanning

  • closeScanner() - Unselect selected scanner

  • close() - Destory connected API Class

Special Function:

  • pixelToInch(pixel) - Convert Pixel(s) to Inch(es) using DPI from setDPI() or default 200

  • cmToInch(cm) - Convert Centimeter(s) to Inch(es)

  • inchTomm(inch) - Convert Inch(es) to Millimeter(s)

  • mmToInch(mm) - Convert Millimeter(s) to Inch(es)

Example:

from pyScanLib import pyScanLib

loadScanner = pyScanLib()
scanners = loadScanner.getScanners()
loadScanner.setScanner(scanners[0])

loadScanner.setDPI(300)
loadScanner.setScanArea(width=512,height=512) #(left,top,width,height)
loadScanner.setPixelType("color") #bw/gray/color

PIL = loadScanner.scan()
PIL.save("scanImage.jpg")
loadScanner.closeScanner() # unselect selected scanner in setScanners()
loadScanner.close() # Destory whole class

Detail Example:

Check exampleUsage.py in repo

Notice:

  • Not tested on Linux however work perfect on Windows.

Used in:

License:

pyScanLib uses BSD 2-Clause 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

pyScanLib-v1.0.zip (5.2 kB view details)

Uploaded Source

File details

Details for the file pyScanLib-v1.0.zip.

File metadata

  • Download URL: pyScanLib-v1.0.zip
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyScanLib-v1.0.zip
Algorithm Hash digest
SHA256 2fe2ea0f15928d920b9db14053025c919efa733d020ae03a737c71dba96c8146
MD5 6d87ed37a825914d88fb2f9c643417b5
BLAKE2b-256 0d6021bafdf89d927b41dcba185ae3b60a4dcae55a30f247447179847abebbcc

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