1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-11-08 13:39:53 +00:00
random-stuff/computercraft/tomapdata.py
2023-11-13 19:37:05 +00:00

14 lines
408 B
Python

import json
from PIL import Image
import os
def chunks(x, l):
return [ x[i:i+l] for i in range(0, len(x), l) ]
ls = []
for f in os.listdir("cc-tiles"):
if "fs8" in f:
im = Image.open(os.path.join("cc-tiles", f))
ls.append(([ int(b.hex().rjust(6, "0"), 16) for b in chunks(im.palette.getdata()[1], 3) ], list(im.getdata())))
print(json.dumps(ls).replace("[", "{").replace("]", "}"))