-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataviz.py
More file actions
37 lines (26 loc) · 819 Bytes
/
dataviz.py
File metadata and controls
37 lines (26 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import Image, ImageDraw, struct, sys, os
if len(sys.argv) != 3:
print "dataviz.py for.exe bar.png"
os._exit(1)
size = ( 256, 256 )
im = Image.new( 'RGB', size )
draw = ImageDraw.Draw( im )
with open(sys.argv[1], "rb") as f:
x = struct.unpack('B', f.read(1))[0]
y = struct.unpack('B', f.read(1))[0]
while True:
try:
r, g, b = im.getpixel( (x, y) )
if r < 255:
draw.point((x, y), fill=( r+2, g, b))
elif g < 255:
draw.point((x, y), fill=( r, g+2, b))
else:
draw.point((x, y), fill=( r, g, b+2))
x = y
y = struct.unpack('B', f.read(1))[0]
except Exception, e:
break
del draw
im.save( sys.argv[2], "PNG")
raw_input("Press Enter to continue...")