我是靠谱客的博主 真实白昼,这篇文章主要介绍python更改图像尺寸resize,现在分享给大家,希望可以做个参考。

from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=256,height=256):
    img=Image.open(jpgfile)
    h, w = img.size
    if h != 256 or w != 256:
        try:
            print(jpgfile,h,w)
            new_img=img.resize((width,height),Image.NEAREST)   #ANTIALIAS
            new_img.save(os.path.join(outdir,os.path.basename(jpgfile)))
        except Exception as e:
            print(e)
for jpgfile in glob.glob("./9-crack776/mask-yuan/*"):
    convertjpg(jpgfile,"./9-crack776/mask")

最后

以上就是真实白昼最近收集整理的关于python更改图像尺寸resize的全部内容,更多相关python更改图像尺寸resize内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(149)

评论列表共有 0 条评论

立即
投稿
返回
顶部