[IMAGE-SIG] PIL/SANE interface

Andrew Kuchling amk@magnet.com
Thu, 19 Jun 1997 17:22:33 -0400 (EDT)

I've completed a first version of a SANE interface for the Python
Imaging Library.  SANE is a freeware API for various raster devices
like scanners and digital cameras; it runs on various Unixen.  The
Python Imaging Library, of course, allows you to read and write images
in various formats, and manipulate them in various ways.  It seems
like a good fit to me...

You can get the code from http://starship.skyport.net/crew/amk/projects/ .  
If you try it out, please let me know how it works for you.

	SANE home page:	http://www.azstarnet.com/~axplinux/sane/
	PIL home page:  http://www.python.org/sigs/image-sig/Imaging.html

Here's a sample script that gets a single image from a QuickCam, and
writes the image out to a GIF file.  The script's output is:

SANE version: (327680, 0, 5, 0)
Available devices= [('qcam:0x378', 'Connectix', 'B&W QuickCam', 'video camera'), 
('pnm:0', 'Noname', 'PNM file reader', 'virtual device'), 
('pnm:1', 'Noname', 'PNM file reader', 'virtual device')]
SaneDev object= <SaneDev instance at 809c5f8>
Device parameters: ('L', 1, (330, 246), 8, 330)

And the script itself is:

#!/bin/env python
# Get the path set up properly
import sys ; sys.path.append('.')

import sane
print 'SANE version:', sane.init()
print 'Available devices=', sane.get_devices()

print 'SaneDev object=', scanner
print 'Device parameters:', scanner.get_parameters()

# Set scan parameters
scanner.contrast=170 ; scanner.brightness=150 ; scanner.white_level=190
scanner.br_x=320 ; scanner.br_y=240

# Initiate the scan

# Get an Image object containing the scanned image
# (For my B&W QuickCam, this is a grey-scale image.  Other scanning devices
#  may return an RGB image, or a single channel of an RGB image.)

# Write the image out as a GIF file

# The show method() simply saves the image to a temporary file and calls "xv".

	Andrew Kuchling

IMAGE-SIG - SIG on Image Processing with Python

send messages to: image-sig@python.org
administrivia to: image-sig-request@python.org