使用Pillow库
使用管理员模式进行pip下载安装pip install Pillow
安装在:C:\Program Files\Python36\Lib\site-packages\Pillow
处理图像:
- 导入PIL库
from PIL import Image
- 读取图片
im = Image.open('D://image.jpg')
- 显示图片
im.show()
- 调整图片大小
(x, y) = im.size # 读取图片大小 new_x = 400 new_y = 400 out = im.resize((new_x, new_y), Image.ANTIALIAS) out.save('D://new_image.jpg')
网友评论