-
Notifications
You must be signed in to change notification settings - Fork 1
/
images.py
31 lines (24 loc) · 1.08 KB
/
images.py
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
import os
import json
directory = "./A/System64/Images/Icons/"
icon_paths = {}
icon_sizes = {"512x512", "256x256", "128x128", "64x64", "48x48", "32x32", "16x16"}
for filename in os.listdir(directory):
if any(size in filename for size in icon_sizes):
# Extract the image name without the size and extension
image_name = os.path.splitext(filename)[0].lower() # Convert to lowercase
# Remove the size from the image name
for size in icon_sizes:
image_name = image_name.replace(f"-{size}", "")
# Construct the full path to the image
image_path = os.path.join(directory, filename)
# Add the image to the icon_paths dictionary
if image_name not in icon_paths:
icon_paths[image_name] = {}
# Add the image path for the respective size
for size in icon_sizes:
if f"{size}" in filename:
icon_paths[image_name][size.split("x")[0]] = image_path
# Output the dictionary
with open("./A/System64/Images/Icons.json", "w") as json_file:
json.dump(icon_paths, json_file, indent=4)