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)
posted @ 2022-06-10 11:22  CJK'sBLOG  阅读(209)  评论(0)    收藏  举报