美文网首页
2018-08-07

2018-08-07

作者: 道法自然FOAF | 来源:发表于2018-08-07 11:33 被阅读23次

    在python中使用pillow修改图片的尺寸大小

    from PIL import Image

    readfile_path=r'./template.png'  #当前图片的路径(相对路径)

    outfile_path=r'./template.png'  #图片保存在当前路径

    width=38  #宽度

    length=38  #长度

    Image.open(readfile_path).convert('RGB').save(outfile_path) # convert the image to RGB mode  very important 将图片转化为RGB模式

    img = Image.open(readfile_path)

    print(img.format, img.size, img.mode, img.info)

    newImg = img.resize((width,length), Image.ANTIALIAS)  #想调整的大小

    print(newImg)

    newImg.save(outfile_path)

    相关文章

      网友评论

          本文标题:2018-08-07

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