-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapology.py
More file actions
36 lines (29 loc) · 855 Bytes
/
Copy pathapology.py
File metadata and controls
36 lines (29 loc) · 855 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
import urllib
import wave
import chunk
import operator
import Image
im = Image.new("RGB",(300,300))
for i in range(25):
s = str(i+1)
fname = 'lake' + s + '.wav'
print "retrieving wave file #" + s
nexturl = 'http://www.pythonchallenge.com/pc/hex/' + fname
myFile = urllib.urlopen(nexturl)
LongString = myFile.read()
myFile.close()
myFile = open(fname,"wb")
myFile.write(LongString)
myFile.close()
myFile = wave.open('lake' + s + ".wav","rb")
mynframes = myFile.getnframes()
myData = myFile.readframes(mynframes)
myFile.close()
print "writing picture piece #" + str(i+1)
yy = (i/5)*60
xx = operator.mod(i,5)*60
for j in range(len(myData)/3):
y = int(j/60) + yy
x = operator.mod(j,60) + xx
im.putpixel((x,y),(ord(myData[j*3]),ord(myData[j*3+1]),ord(myData[j*3+2]),255))
im.save("lake2.png")