编程语言
首页 > 编程语言> > python创建icon图标

python创建icon图标

作者:互联网

def extension_replace(path,extension):
    for i in range(1,len(path)):
        if (path[-i] == '.'):
            new_path = path.replace(path[-i+1:],extension)
            break
    return new_path

path = '1.jpg'
img = PIL.Image.open(path)
size = (128,128)
icon = img.resize(size,PIL.Image.LANCZOS) #提取像素
name = extension_replace(path,'ico') #替换文件后缀名
icon.save(name)

标签:size,PIL,extension,python,replace,path,icon,图标
来源: https://www.cnblogs.com/chengjunkai/p/16362594.html