awips2/pythonPackages/pil/Sane/demo_pil.py
root 2b462d8665 Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 06a8b51d6d [formerly a02aeb236c [formerly 9f19e3f712] [formerly 06a8b51d6d [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]]
Former-commit-id: a02aeb236c [formerly 9f19e3f712]
Former-commit-id: a02aeb236c
Former-commit-id: 133dc97f67
2012-01-06 08:55:05 -06:00

33 lines
719 B
Python

#!/usr/bin/env python
#
# Shows how to scan a color image into a PIL rgb-image
#
# Get the path set up to find PIL modules if not installed yet:
import sys ; sys.path.append('../PIL')
import sane
print 'SANE version:', sane.init()
print 'Available devices=', sane.get_devices()
s = sane.open(sane.get_devices()[0][0])
s.mode = 'color'
s.br_x=320. ; s.br_y=240.
print 'Device parameters:', s.get_parameters()
# Initiate the scan
s.start()
# Get an Image object
# (For my B&W QuickCam, this is a grey-scale image. Other scanning devices
# may return a
im=s.snap()
# Write the image out as a GIF file
#im.save('foo.gif')
# The show method() simply saves the image to a temporary file and calls "xv".
im.show()