Files
d330viewer/resources/convert_to_ico.py
2026-01-14 18:07:26 +08:00

17 lines
542 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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!")