美文网首页
python处理图像--调整图片大小

python处理图像--调整图片大小

作者: 五秋木 | 来源:发表于2017-11-18 10:57 被阅读0次

使用Pillow库
使用管理员模式进行pip下载安装pip install Pillow
安装在:C:\Program Files\Python36\Lib\site-packages\Pillow
处理图像:

  1. 导入PIL库from PIL import Image
  2. 读取图片im = Image.open('D://image.jpg')
  3. 显示图片im.show()
  4. 调整图片大小
    (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')
    

相关文章

网友评论

      本文标题:python处理图像--调整图片大小

      本文链接:https://www.haomeiwen.com/subject/wlgnmxtx.html