Coder Social home page Coder Social logo

pyscanlib's Introduction

pyScanLib

An combination of Twain and SANE API

Requirements:

  • Python 2.6/2.7 (Windows)
  • Python 2.6-3.4 (Linux)
  • SANE API for Linux, Mac OS
  • TWAIN API 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
  • getScannerSize() - Return scanner size eg. (left, top, right, bottom)
  • 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)
  • cmToInch(cm) - Convert Centimeter(s) to Inch(es)
  • inchTomm(inch) - Convert Inch(es) to Millimeter(s)
  • mmToInch(mm) - Convert Millimeter(s) to Inch(es)

Library Installation:

  • Linux or Mac OS
  • brew install sane-backends
  • pip install python-sane
  • Windows

Example:

    from pyScanLib import pyScanLib

    ls = pyScanLib() # load scanner library
    devices = ls.getScanners()
    ls.setScanner(devices[0])

    ls.setDPI(300)
    
    # A4 Example
    ls.setScanArea(width=8.26,height=11.693) # (left,top,width,height) in inches

    ls.setPixelType("color") # bw/gray/color

    pil = ls.scan()
    pil.show()
    pil.save("scannedImage.jpg")
    
    ls.closeScanner() # unselect selected scanner, set in setScanners()
    ls.close() # Destory whole class

Detail Example:

Check exampleUsage.py in repo

Notice:

  • Known to work on Linux (Python 3.4) Pull #1
  • Known to work on Mac OS Pull #2
  • Not tested on Linux by author, however work perfect on Windows.

TODO:

  • Implement scanPreview()

License:

pyScanLib uses BSD 2-Clause License.

pyscanlib's People

Contributors

soachishti avatar bg4hkq avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.