一个特殊的python图像子模块,供初学者使用。

image_novice的Python项目详细描述


一个特殊的python图像子模块,供初学者使用。

说明

image_新手是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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在设置AtomicBoolean之前检查另一个条件?   通过java将文件从windows计算机复制到另一台windows计算机   java如何在使用Cobertura时忽略与记录器相关的If条件?   java无法在Eclipse中导出Android应用程序   带GSON的java parse JSON返回null   java Extract/filter Splunk查询和条件逻辑   java ProgressBar带有一个倒计时器Android   java我应该为每个DAO编写通用方法的集成测试吗?   java从命令行访问执行JAR的文本文件   任务应用程序的java Gradle生成失败:processReleaseResources   预测函数的java DeepLearning4j NN不收敛   java如果发现特殊字符,如何删除字符串中的字符?   在Java中,从精确位置将字符串拆分为两个   将Java ByteArrayOutputStream压缩到不同的容器中   带有同心指示方块的java太空船模拟器制导计算机   java如何使用Jericho解析两条注释?   PersistenceUnit中的java多个类   连接到java中的elasticsearch?   当嵌入HTML页面时,删除java小程序中的外部白色边框   用于webstart的java CXF ClassCastException(SEIStub/ClientProxy)