功能:
将WEBP图象文件转换为JPG格式图象,保存jpg文件移除webp文件
日期:
2020/04/30
作者:
superFAN
注意:
pillow 5.1版本提示:cannot identify image file ‘example.webp’
更新pillow至7.x版本,正常工作
from PIL import Image
import os
def webp2jpg(imgPath):
"""
将WebP图象文件转换为JPG格式图象,保存jpg文件移除webp文件
:param imgPath: 图象文件路径
:return: 无
"""
img = Image.open(imgPath)
newName = imgpath.split('.')[0] + '.jpg'
img.save(newName)
os.remove(imgPath)
if __name__ == '__main__':
"""测试"""
imgpath = 'example.webp'
webp2jpg(imgpath)