[Image-SIG] Getting an error in Point operations code from the pil-handbook.
David McDonnell
David McDonnell" <dave@blinkworks.com.au
Thu, 24 Apr 2003 16:32:37 +0800
I've just started to use python 2.2 and have installed PIL 1.1.4a4 (win 32
installer, this was the only version i could get to install correctly). I
was trying to use the example code from the PIL handbook (1.1.3).
# split the image into individual bands
source = im.split()
R, G, B = 0, 1, 2
# select regions where red is less than 100
mask = source[R].point(lambda i: i 100 and 255)
# process the green band
out = source[G].point(lambda i: i * 0.7)
# paste the processed band back, but only where red was 100
source[G].paste(out, None, mask)
# build a new multiband image
im = Image.merge(im.mode, source)
but i get a syntax error:
File "C:\Python22\Scripts\dave_demo\PILtest.py", line 8
mask = source[R].point(lambda i: i 100 and 255)
^
SyntaxError: invalid syntax
anyone got any ideas? Also if anyone can explain to me how lambda works etc
or point to me to the right place in the docs etc i'd really appreciate it,
cos i cant find anything that i can actually understand about it.
Cheers
Dave
__________________________________
David McDonnell - 3D Artist - Blinkworks
dave@blinkworks.com.au
www.blinkworks.com.au
__________________________________