-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_icon.py
More file actions
32 lines (25 loc) · 1.1 KB
/
Copy pathconvert_icon.py
File metadata and controls
32 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from PIL import Image
import os
# Source and target paths
source_path = r"C:/Users/shelld/.gemini/antigravity/brain/1394dacc-f3af-4c54-ab61-06af7a3ca932/quantagent_app_icon_1768926494626.png"
target_dir = r"D:\股票\同花顺软件\QuantAgent\web\public\icons"
target_ico = os.path.join(target_dir, "ico.ico")
target_png = os.path.join(target_dir, "pwa-192x192.png")
target_png_large = os.path.join(target_dir, "pwa-512x512.png")
# Ensure directory exists
os.makedirs(target_dir, exist_ok=True)
try:
# Open image
img = Image.open(source_path)
# Save as ICO (containing multiple sizes)
img.save(target_ico, format='ICO', sizes=[(256, 256), (128, 128), (64, 64), (32, 32), (16, 16)])
print(f"Successfully saved {target_ico}")
# Save as PNGs for PWA
img_192 = img.resize((192, 192), Image.Resampling.LANCZOS)
img_192.save(target_png)
print(f"Successfully saved {target_png}")
img_512 = img.resize((512, 512), Image.Resampling.LANCZOS)
img_512.save(target_png_large)
print(f"Successfully saved {target_png_large}")
except Exception as e:
print(f"Error: {e}")