26 lines
697 B
Python
26 lines
697 B
Python
|
from PIL import Image
|
||
|
import numpy as np
|
||
|
import base64
|
||
|
import sys
|
||
|
|
||
|
path = sys.argv[1]
|
||
|
print("Using file:", path)
|
||
|
img = Image.open(path)
|
||
|
img = img.convert("RGBA")
|
||
|
# shape should be (height, width, 4)
|
||
|
imgarray = np.asarray(img)
|
||
|
print(imgarray.shape)
|
||
|
# shape should be (width, height, 4)
|
||
|
#imgarray = np.swapaxes(imgarray, 0, 1)
|
||
|
print(imgarray.shape)
|
||
|
# raw data as bytestring
|
||
|
imgdata = imgarray.tobytes("C")
|
||
|
b64data = base64.b64encode(imgdata)
|
||
|
|
||
|
#imgarray = np.asarray(Image.open("skin.png"))
|
||
|
#print(imgarray.shape, imgarray)
|
||
|
#with open("skin.png", "rb") as file:
|
||
|
# raw_data = file.read()
|
||
|
with open("skin.lua", "wb") as file:
|
||
|
file.write(b'return {skin_b64="' + b64data + b'", slim_arms=false}')
|