from PIL import Image
filename = "gbemu-saveload"
img = Image.open(filename+".bmp")
img = img.convert('RGB')
pixels = img.load()
w,h = img.size
f = open(filename+".img", "wb")
for y in range(h):
for x in range(w):
r,g,b = pixels[x,y]
p = 0x8000
p |= r>>3
p |= (g>>3)<<5
p |= (b>>3)<<10
f.write((p & 0x00FF).to_bytes())
f.write(((p & 0xFF00) >> 8).to_bytes())
f.close()
It takes a bmp and converts it into PSMCT16 (RGBA16) format.