From 03c524226922262ee257c79a20fe22c29c3b6ecb Mon Sep 17 00:00:00 2001 From: Shuge Lee Date: Wed, 16 Jan 2013 10:59:22 +0800 Subject: [PATCH] Small changed, fixed spell pixsel -> pixel --- Demos/README.md | 31 +++++++++++-------- .../access_pixels.py} | 10 +++--- 2 files changed, 23 insertions(+), 18 deletions(-) rename Demos/{access_pixsel/access_pixsel.py => access_pixels/access_pixels.py} (80%) diff --git a/Demos/README.md b/Demos/README.md index 9dcadf9f3..d3c943aa2 100644 --- a/Demos/README.md +++ b/Demos/README.md @@ -1,20 +1,12 @@ -# Resources About PIL +# About -PIL Handbook +Some simple Pillow demos - - http://www.pythonware.com/library/pil/handbook/index.htm - - -PIL Tutorial - - - http://www.pythonware.com/library/pil/handbook/introduction.htm - - http://nadiana.com/category/pil - - -## Image used in these demos +how to run + [ -d image_resources ] || mkdir image_resources wget http://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg -O image_resources/captcha.jpg - + python crop/croip.py ## Build it on Mac OS X 10.6.* @@ -34,3 +26,16 @@ Build an egg for x86_64 with Python 2.7(install it via MacPorts) ## Install it via package management system HomeBrew is cool, you could use it instead of MacPorts on OS X. + + +## See also + +PIL Handbook + + - http://www.pythonware.com/library/pil/handbook/index.htm + + +PIL Tutorial + + - http://www.pythonware.com/library/pil/handbook/introduction.htm + - http://nadiana.com/category/pil diff --git a/Demos/access_pixsel/access_pixsel.py b/Demos/access_pixels/access_pixels.py similarity index 80% rename from Demos/access_pixsel/access_pixsel.py rename to Demos/access_pixels/access_pixels.py index 3c92f815b..b32caea28 100644 --- a/Demos/access_pixsel/access_pixsel.py +++ b/Demos/access_pixels/access_pixels.py @@ -9,23 +9,23 @@ file_path = os.path.join(parent_path, "image_resources", "captcha.jpg") im = Image.open(fp = file_path) im = im.draft("L", im.size) w, h = im.size[0], im.size[1] -pixsels = im.load() +pixels = im.load() print "width:", w print "high:", h -print "white(255) ~ black(0):", pixsels[0, 0] +print "white(255) ~ black(0):", pixels[0, 0] def print_im(im, w=None, h=None): if isinstance(im, Image.Image): w, h = im.size[0], im.size[1] - pixsels = im.load() + pixels = im.load() else: - pixsels = im + pixels = im for x in xrange(w): for y in xrange(h): - if pixsels[x, y] > 128: + if pixels[x, y] > 128: print " ", else: print "1",