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.
2005-11-08 10:18:09 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
from PIL import Image
|
|
|
|
import sys
|
2005-11-09 20:10:38 +01:00
|
|
|
import os
|
2005-11-08 10:18:09 +01:00
|
|
|
|
|
|
|
"""Convert image to raw binary using Python Imaging Library."""
|
|
|
|
|
|
|
|
if len(sys.argv) != 3:
|
2005-11-09 20:10:38 +01:00
|
|
|
print "Usage: %s <source> <target>" % os.path.split(sys.argv[0])[1]
|
2005-11-08 10:18:09 +01:00
|
|
|
print "WARNING: It only converts 8x8 pixel images at 8bit the moment."
|
2005-11-09 20:10:38 +01:00
|
|
|
sys.exit()
|
2005-11-08 10:18:09 +01:00
|
|
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
|