Created
January 3, 2023 00:51
Revisions
-
vgmoose revised this gist
Jan 3, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
vgmoose created this gist
Jan 3, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ 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)