mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-02 19:40:10 +03:00
Small changed, fixed spell pixsel -> pixel
This commit is contained in:
parent
d22ae7a3ad
commit
03c5242269
|
@ -1,20 +1,12 @@
|
||||||
# Resources About PIL
|
# About
|
||||||
|
|
||||||
PIL Handbook
|
Some simple Pillow demos
|
||||||
|
|
||||||
- http://www.pythonware.com/library/pil/handbook/index.htm
|
how to run
|
||||||
|
|
||||||
|
|
||||||
PIL Tutorial
|
|
||||||
|
|
||||||
- http://www.pythonware.com/library/pil/handbook/introduction.htm
|
|
||||||
- http://nadiana.com/category/pil
|
|
||||||
|
|
||||||
|
|
||||||
## Image used in these demos
|
|
||||||
|
|
||||||
|
[ -d image_resources ] || mkdir image_resources
|
||||||
wget http://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg -O image_resources/captcha.jpg
|
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.*
|
## 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
|
## Install it via package management system
|
||||||
|
|
||||||
HomeBrew is cool, you could use it instead of MacPorts on OS X.
|
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
|
||||||
|
|
|
@ -9,23 +9,23 @@ file_path = os.path.join(parent_path, "image_resources", "captcha.jpg")
|
||||||
im = Image.open(fp = file_path)
|
im = Image.open(fp = file_path)
|
||||||
im = im.draft("L", im.size)
|
im = im.draft("L", im.size)
|
||||||
w, h = im.size[0], im.size[1]
|
w, h = im.size[0], im.size[1]
|
||||||
pixsels = im.load()
|
pixels = im.load()
|
||||||
|
|
||||||
print "width:", w
|
print "width:", w
|
||||||
print "high:", h
|
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):
|
def print_im(im, w=None, h=None):
|
||||||
if isinstance(im, Image.Image):
|
if isinstance(im, Image.Image):
|
||||||
w, h = im.size[0], im.size[1]
|
w, h = im.size[0], im.size[1]
|
||||||
pixsels = im.load()
|
pixels = im.load()
|
||||||
else:
|
else:
|
||||||
pixsels = im
|
pixels = im
|
||||||
|
|
||||||
for x in xrange(w):
|
for x in xrange(w):
|
||||||
for y in xrange(h):
|
for y in xrange(h):
|
||||||
|
|
||||||
if pixsels[x, y] > 128:
|
if pixels[x, y] > 128:
|
||||||
print " ",
|
print " ",
|
||||||
else:
|
else:
|
||||||
print "1",
|
print "1",
|
Loading…
Reference in New Issue
Block a user