专为初学者设计的Python图像子模块。
项目描述
专为初学者设计的Python图像子模块。
描述
image_novice是Python图像库(PIL)的一个简单包装器,适用于初学者。它允许轻松加载、操作和保存图像文件。
注意:此模块使用笛卡尔坐标系!
示例
>>> import image_novice as novice # special submodule for beginners
>>> picture = novice.open('sample.png') # create a picture object from a file
>>> print picture.format # pictures know their format...
'png'
>>> print picture.path # ...and where they came from...
'/Users/example/sample.png'
>>> print picture.size # ...and their size
(665, 500)
>>> print picture.width # 'width' and 'height' also exposed
665
>>> picture.size = (200, 250) # changing size automatically resizes
>>> for pixel in picture: # can iterate over pixels
>>> ... if ((pixel.red > 128) and # pixels have RGB (values are 0-255)...
>>> ... (pixel.x < picture.width)): # ...and know where they are
>>> ... pixel.red /= 2 # pixel is an alias into the picture
>>> ...
>>> print picture.modified # pictures know if their pixels are dirty
True
>>> print picture.path # picture no longer corresponds to file
None
>>> picture[0:20, 0:20] = (0, 0, 0) # overwrite lower-left rectangle with black
>>> picture.save('sample-bluegreen.jpg') # guess file type from suffix
>>> print picture.path # picture now corresponds to file
'/Users/example/sample-bluegreen.jpg'
>>> print picture.format # ...has a different format
jpeg
>>> print picture.modified # and is now in sync
False
项目详情
关闭
image_novice-0.1.3.tar.gz的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | ea242a3a3fd0842b4dc81bdae3f8e23575092c44b751c2cff26260faaace44ce |
|
| MD5 | 6469ab80b113c35d097b1ab85d7299bc |
|
| BLAKE2b-256 | d6bebe7e35d57567c1a15c02bd2946b0960ca18118768e930865a3fae3161aae |