街角_祝福

导航

pythonchallenge--7

import Image
im = Image.open('oxygen.png')
print ('image information:',im.format,im.size,im.mode)
y_begin = 0
while True:
    p = im.getpixel((0,y_begin))
    if p[0] == p[1] == p[2]:
        break
    y_begin += 1
x_end = 0
while True:
    p = im.getpixel((x_end,y_begin))
    if not p[0] == p[1] == p[2]:
        break
    x_end += 1
print('Y first corrdinate:',y_begin,'X last coordinate:x_end:',x_end)
msg = []
for i in range(0,x_end,7):
    p = im.getpixel((i,y_begin))
    msg.append(chr(p[0]))
print(''.join(msg))
msg = [105, 110, 116, 101, 103, 114, 105, 116, 121]
print(''.join([chr(x) for x in msg]))

posted on 2012-08-13 08:56  街角_祝福  阅读(146)  评论(0编辑  收藏  举报