summaryrefslogtreecommitdiff
path: root/newimagefromjson.py
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-02-16 00:10:13 -0800
committeryo mama <pepper@scannerjammer.com>2015-02-16 00:10:13 -0800
commit760c35f835ef179bc398abc57bcea39bc9ec401e (patch)
tree6fddb5f6b55c898a68e4bb3826d0fc524007ca40 /newimagefromjson.py
parentc3b34223ef6390ad2801edaa3e3b825c7df1cb98 (diff)
finishing mode
Diffstat (limited to 'newimagefromjson.py')
-rw-r--r--newimagefromjson.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/newimagefromjson.py b/newimagefromjson.py
index 25fdfcd..5f62bd1 100644
--- a/newimagefromjson.py
+++ b/newimagefromjson.py
@@ -1,13 +1,14 @@
#!/usr/bin/python2.7
import simplejson as json
-import Image
+from PIL import Image
+import sys
-f = open("jsonfile", 'r');
+f = open("myjson.json", 'r');
myjson = f.read();
f.close();
specs = json.loads(myjson);
-img = Image.new('RGBA', (int(specs.width), int(specs.height), "black"));
+img = Image.new('RGBA', (int(specs['width']), int(specs['height'])));
def boolToColor(boolean):
if boolean:
@@ -16,17 +17,10 @@ def boolToColor(boolean):
return (255,255,255,0)
pixels = img.load();
-for i in specs.matrix:
- for j in specs.matrix[i]:
- pixels[i,j] = boolToColor(specs.matrix[i][j]);
-
-
-img = Image.new( 'RGBA', (500,500), "black") # create a new black image
-pixels = img.load() # create the pixel map
-
-
-for i in range(img.size[0]): # for every pixel:
- for j in range(img.size[1]):
- pixels[i,j] = (255, 255, 255, 255) # set the colour accordingly
+#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")