mirror of
https://github.com/osmarks/random-stuff
synced 2024-12-29 11:30:35 +00:00
14 lines
408 B
Python
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("]", "}"))
|