Chris said:
How long did it take you to type all that?
Heh, I don't have quite *that* much time on my hands. I used a
quick-and-dirty Python script:
import Image
def chunks(seq, chunk_size=2):
"""This function returns a generator which iterates over the chunks
of a sequence. The first argument is the sequence to find chunks
of, and the second is the size of chunks (defaults to 2). For
instance, chunks("foobar", 2) will iterate over "fo", "ob", "ar".
"""
for chunk_start in xrange(0, len(seq), chunk_size):
chunk_end = chunk_start + chunk_size
yield seq[chunk_start:chunk_end]
img = Image.open('dandelion.jpeg')
html = open('image.html', 'w')
html.write('''<style type="text/css">
td {
width : 1px;
height : 1px;
}
</style>
<table cellspacing="0" cellpadding="0">\n''')
for line in chunks(list(img.getdata()), img.size[0]):
html.write('<tr>')
for pixel in line:
html.write('<td bgcolor="#%02X%02X%02X"></td>' % pixel)
html.write('</tr>\n')
html.write('</table>')