~ubuntu-branches/debian/squeeze/python-imaging/squeeze

« back to all changes in this revision

Viewing changes to Sane/demo_pil.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-08-28 23:14:10 UTC
  • mfrom: (2.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20060828231410-lca9enmne3ecmkup
Tags: 1.1.5-11
* python-imaging-sane: Depend on python-numarray. Closes: #382190.
* Add dependencies on ${shlibs:Depends}, lost in -6. Closes: #378596.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
#
 
4
# Shows how to scan a color image into a PIL rgb-image
 
5
#
 
6
 
 
7
# Get the path set up to find PIL modules if not installed yet:
 
8
import sys ; sys.path.append('../PIL')
 
9
 
 
10
import sane
 
11
print 'SANE version:', sane.init()
 
12
print 'Available devices=', sane.get_devices()
 
13
 
 
14
s = sane.open(sane.get_devices()[0][0])
 
15
 
 
16
s.mode = 'color'
 
17
s.br_x=320. ; s.br_y=240.
 
18
 
 
19
print 'Device parameters:', s.get_parameters()
 
20
 
 
21
# Initiate the scan
 
22
s.start()
 
23
 
 
24
# Get an Image object 
 
25
# (For my B&W QuickCam, this is a grey-scale image.  Other scanning devices
 
26
#  may return a 
 
27
im=s.snap()
 
28
 
 
29
# Write the image out as a GIF file
 
30
#im.save('foo.gif')
 
31
 
 
32
# The show method() simply saves the image to a temporary file and calls "xv".
 
33
im.show()