diff options
Diffstat (limited to 'share/frontend/impattern/newimagefromjson.py')
| -rw-r--r-- | share/frontend/impattern/newimagefromjson.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/share/frontend/impattern/newimagefromjson.py b/share/frontend/impattern/newimagefromjson.py new file mode 100644 index 0000000..5f62bd1 --- /dev/null +++ b/share/frontend/impattern/newimagefromjson.py @@ -0,0 +1,26 @@ +#!/usr/bin/python2.7 +import simplejson as json +from PIL import Image +import sys + +f = open("myjson.json", 'r'); +myjson = f.read(); +f.close(); + +specs = json.loads(myjson); +img = Image.new('RGBA', (int(specs['width']), int(specs['height']))); + +def boolToColor(boolean): + if boolean: + return (0,0,0,255); + else: + return (255,255,255,0) + +pixels = img.load(); +#for i in range(0, 9, 2): +# dosomething(i) +for i in range(0, len(specs['matrix'])): + for j in range(0, len(specs['matrix'][i])): + pixels[j,i] = boolToColor(int(specs['matrix'][i][j])); + +img.save("myimage.png", "PNG") |
