Created
June 24, 2025 18:54
-
-
Save undefined06855/56b064928771b20dab724b3c6d7f293f to your computer and use it in GitHub Desktop.
most average geode mod icon generator(tm)
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 characters
| # usage: python average.py <type (mean|median)> <id author (optional)> | |
| import sys | |
| from PIL import Image | |
| import numpy as np | |
| import json | |
| mod_ids = [] | |
| if len(sys.argv) == 2: | |
| sys.argv = [ sys.argv[0], sys.argv[1], "" ] | |
| elif len(sys.argv) == 1: | |
| print("what do i do mean or median and for who") | |
| exit(1) | |
| print(f"getting {sys.argv[1]} for {sys.argv[2]}") | |
| with open("./mods.json", "r") as file: | |
| mods = json.loads(file.read()) | |
| for mod in mods: | |
| mod_ids.append(mod["id"]) | |
| mod_icons = [] | |
| for id in mod_ids: | |
| if sys.argv[2] not in id: | |
| continue | |
| image = Image.open(f"./icons/{id}.png") | |
| image = image.resize((336, 336)).convert("RGBA") | |
| mod_icons.append(image) | |
| # thakns chatgpt | |
| def average_images(image_list): | |
| # Convert all images to numpy arrays | |
| arrays = [np.array(img, dtype=np.float32) for img in image_list] | |
| # Stack arrays and compute the mean | |
| mean_array = None | |
| if sys.argv[1] == "median": | |
| mean_array = np.median(arrays, axis=0) | |
| else: | |
| mean_array = np.mean(arrays, axis=0) | |
| # Convert back to uint8 and then to a Pillow image | |
| mean_image = Image.fromarray(mean_array.astype(np.uint8)) | |
| return mean_image | |
| average_images(mod_icons).save(f"./{sys.argv[2]}-{sys.argv[1]}.png") |
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 characters
| // this is actually beautiful code i know | |
| const fs = require("fs") | |
| !(async () => { | |
| let mods = [] | |
| let amountOfMods = 100 | |
| for (let start = 0; start < amountOfMods + 200; start += 100) { | |
| let page = start / 100 | |
| let res = await fetch(`https://api.geode-sdk.org/v1/mods?per_page=${100}&page=${page}`) | |
| let json = await res.json() | |
| let data = json.payload.data | |
| amountOfMods = json.payload.count | |
| mods.push(...data) | |
| console.log(page, amountOfMods - start) | |
| } | |
| fs.writeFileSync("./mods.json", JSON.stringify(mods, null, " ")) | |
| console.log("done") | |
| /** @type {Array<Record<string, any>>} */ | |
| // let mods = JSON.parse(fs.readFileSync("./mods.json")) | |
| console.log("fetching...") | |
| // fetch icons | |
| let icons = [] | |
| for (let mod of mods) { | |
| console.log(mod.id) | |
| let res = await fetch(`https://api.geode-sdk.org/v1/mods/${mod.id}/logo`) | |
| if (res.status != 200) continue | |
| let buf = Buffer.from(await res.arrayBuffer()) | |
| icons.push([ mod.id, buf ]) | |
| } | |
| // write icons | |
| console.log("fetched, write icons...") | |
| for (let icon of icons) { | |
| console.log(icon[0]) | |
| fs.writeFileSync(`./icons/${icon[0]}.png`, icon[1]) | |
| } | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
im a big fan