Skip to content

Instantly share code, notes, and snippets.

@Parcly-Taxel
Last active September 5, 2021 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Parcly-Taxel/f6ec37e8bf7ff5af044346879da0fa1d to your computer and use it in GitHub Desktop.
Save Parcly-Taxel/f6ec37e8bf7ff5af044346879da0fa1d to your computer and use it in GitHub Desktop.
Periodic Ponies composite assembly code
#!/usr/bin/env python3
import requests, time
import numpy as np
# e621 script that added "index notes" to the periodic table
PT = np.array([[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2],
[ 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 9, 10],
[11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],
[37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54],
[55, 56, 0, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86],
[87, 88, 0,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118],
[ 0, 0, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 0],
[ 0, 0, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103, 0]])
e6posts = "669950 669955 669956 669959 669961 669964 669968 669973 669976 669977 669979 669981 669983 669985 669987 669990 669992 669995 669996 669997 669999 670002 670005 670007 670011 670014 670015 670017 670020 670022 670026 670027 670028 670035 670029 670031 670044 670046 670048 670052 670053 670055 670056 670057 670061 670064 670072 670243 670244 670245 670246 670248 670250 670393 670439 670449 670487 670494 670497 672352 672362 672380 683088 686155 686177 688304 688336 689006 691172 691173 691175 693841 717828 724931 724935 724936 753276 797474 803268 2283593 2297603 2307065 2307109 2317105 2317110 2317126 2324430 2331476 2331482 2331494 2332405 2355830 2366533 2391104 2394788 2403579 2418309 2421875 2423030 2423031 2446305 2458137 2459875 2884449 2880503 2781406 2835830 2887913 2886200 2544683 2867626 2841341 2894377 2784896 2910708 2727759 2805355 2882123"
e6posts = [int(x) for x in e6posts.split()]
e6headers = {"User-Agent": "parclytaxel's Periodic Ponies Note-Adder for e621"}
for Z in range(1, 119):
y, x = (PT == Z).nonzero()
nx = x[0]*800 + 460
ny = y[0]*1000 + 20
e6post = e6posts[1]
e6params = {"login": "name", "api_key": "key"}
e6params.update({"note[post_id]": "2912444", "note[x]": str(nx), "note[y]": str(ny),
"note[width]": "300", "note[height]": "300", "note[body]": f"post #{e6posts[Z-1]}"})
r = requests.post("https://e621.net/notes.json", params=e6params, headers=e6headers)
print(Z, r.json())
time.sleep(90)
#!/usr/bin/env python3
from glob import glob
import numpy as np
from PIL import Image
# For an archive of all the files, including the source pictures and the two
# little scripts here, see https://parclytaxel.fanbox.cc/posts/2698843
PT = np.array([[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2],
[ 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 9, 10],
[11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],
[37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54],
[55, 56, 0, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86],
[87, 88, 0,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118],
[ 0, 0, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 0],
[ 0, 0, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103, 0]])
res = Image.new("RGBA", (PT.shape[1]*800, PT.shape[0]*1000), (0, 0, 0, 0))
border = Image.open("border.png")
for Z in range(1, 119):
partim = Image.open(glob(f"{Z}.*")[0]).convert("RGBA")
y, x = (PT == Z).nonzero()
res.paste(Image.alpha_composite(partim, border), (x[0]*800, y[0]*1000))
res.save("out.png")
#!/usr/bin/env python3
import requests, shutil
Z = 79
# This program extracts joycall6's images from Derpibooru
for page in range(1, 7):
r = requests.get("https://derpibooru.org/api/v1/json/search/images", params={"q": "aspect_ratio:0.8, artist:joycall6, joycall6's periodic table", "page": page})
for imres in r.json()["images"]:
print(Z, imres["representations"]["full"])
with open(f"{Z}.jpg", 'wb') as fd:
for chunk in requests.get(imres["representations"]["full"]):
fd.write(chunk)
Z -= 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment