17 lines
542 B
Python
17 lines
542 B
Python
#!/usr/bin/env python3
|
||
"""将PNG图标转换为ICO格式"""
|
||
|
||
from PIL import Image
|
||
import os
|
||
|
||
def png_to_ico(png_path, ico_path):
|
||
"""将PNG转换为ICO"""
|
||
img = Image.open(png_path)
|
||
# ICO文件支持多种尺寸,Windows会根据需要选择合适的尺寸
|
||
img.save(ico_path, format='ICO', sizes=[(16, 16), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)])
|
||
print(f"Created: {ico_path}")
|
||
|
||
if __name__ == "__main__":
|
||
png_to_ico("icons/app_icon.png", "app_icon.ico")
|
||
print("\nICO file generated successfully!")
|