Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created January 3, 2023 00:51
Show Gist options
  • Save vgmoose/641342cea457d93b1fb2e15cbfa61a49 to your computer and use it in GitHub Desktop.
Save vgmoose/641342cea457d93b1fb2e15cbfa61a49 to your computer and use it in GitHub Desktop.
aroma warning banner icon generator for wiiu apps
from PIL import Image
import requests
import os
from io import BytesIO
# get all the aroma apps
REPO_URL = "https://wiiubru.com/appstore/repo.json"
r = requests.get(REPO_URL)
packages = list(map(lambda p: p["name"], filter(lambda p: p["category"] == "aroma", r.json()["packages"])))
# assume the overlay path exists, and has the right dimensions
overlay_path = "overlay.png"
# go through each package and download their icon and add the overlay
URL = "https://wiiubru.com/appstore/packages/{package}/icon.png"
r = requests.get(URL)
for pkg in packages:
os.makedirs(f"output/{pkg}", exist_ok=True)
with open(f"output/{pkg}/screen.png", "wb") as f:
print(f"Processing {pkg}...")
# create a new blank 767x193 image
new_img = Image.new("RGBA", (767, 193))
# get the icon image (assume it exists)
icon_img = Image.open(BytesIO(requests.get(URL.format(package=pkg)).content))
# get height and width of icon
icon_width, icon_height = icon_img.size
# get the overlay image
overlay_img = Image.open(overlay_path)
# scale the icon to fit in the new image (half the banner height)
icon_img = icon_img.resize((int(icon_width * 96 / icon_height), 96))
# fill a background color of the top left pixel of the icon
new_img.paste(icon_img.getpixel((0, 0)), (0, 0, 767, 193))
# paste the icon in the middle center of the new image
new_img.paste(icon_img, (int((767 - icon_img.size[0]) / 2), 96))
# paste the overlay on top of the icon
new_img.paste(overlay_img, (0, 0), overlay_img)
# save the new image
new_img.save(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment