PIL库

Image模块是在Python PIL图像处理中常见的模块,对图像进行基础操作的功能基本都包含于此模块内。如open、save、conver、show…等功能。

from PIL import Image
m = Image.open("D:\\picture.jpg")

生成缩略图:

im.thumbnail((128, 128))   
im.save("birdnestTN","JPEG")
im.show() 

旋转和缩放:

im.rotate(45)   
im.resize(128)   
im.show()

图像颜色交换

r, g, b = im.split()  
om = Image.merge("RGB", (b, g, r))   
om.save('pictureBGR.jpg')
posted @ 2020-04-15 09:36  睡务局局长  阅读(117)  评论(0)    收藏  举报