目录
1、目前从网上下了很多图片是webp格式结尾的:
2、通过引入pil包实现转换:
1、目前从网上下了很多图片是webp格式结尾的:
在直接使用时可能某些软件不支持这种格式的使用,需要进行转换,通过下载PIL包:
# 安装python的Pillow包pip install Pillow
2、通过引入pil包实现转换:
# coding:utf-8from PIL import Image# 此处路径格式的引用需要使用双斜杠,要不无法访问到目标路径filename = 'C:\\Users\\Pictures\\树林.webp'im = Image.open(filename)if im.mode == "RGBA":im.load() # required for png.split()background = Image.new("RGB", im.size, (255, 255, 255))background.paste(im, mask=im.split()[3])save_name = filename.replace('webp', 'jpg')# 此处会保存到源filename路径下im.save('{}'.format(save_name), 'JPEG')