mirror of
https://github.com/alopexc0de/pixopixel.git
synced 2024-12-26 15:02:39 +00:00
20 lines
391 B
Python
20 lines
391 B
Python
import sys
|
|
from PIL import Image
|
|
|
|
|
|
img = sys.argv[1]
|
|
size = 16, 16
|
|
|
|
im = Image.open(img)
|
|
smallim = im.resize(size, Image.ANTIALIAS);
|
|
smallim = smallim.convert('RGB')
|
|
pixels = list(smallim.getdata())
|
|
|
|
imgstr = str(pixels).strip('[]')
|
|
imgstr = imgstr.replace('(','{')
|
|
imgstr = imgstr.replace(')','}')
|
|
|
|
f = open(img + '.h', 'w')
|
|
f.write('int imageArray[256][3] = {' + imgstr + '};')
|
|
f.close()
|