tangstad/helds
tangstad
/
helds
Archived
1
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
helds/gba/tools/img2bin.py

21 lines
469 B
Python

#!/usr/bin/python
from PIL import Image
import sys
import os
"""Convert image to raw binary using Python Imaging Library."""
if len(sys.argv) != 3:
print "Usage: %s <source> <target>" % os.path.split(sys.argv[0])[1]
print "WARNING: It only converts 8x8 pixel images at 8bit the moment."
sys.exit()
im = Image.open(sys.argv[1])
output = open(sys.argv[2], "wb")
for x in range(8):
for y in range(8):
val = im.getpixel((x, y))
output.write(chr(val))