FW: This code performs the rather esoteric function of converting an image file to a raw HTML page, using a <table> tag with a cell for each pixel. The output is, of course, huge, and will crash some older browsers or systems. The only use I can think of this is if you had a hosting service which had tons of bandwidth but didn't support images, and really needed one.
Yes, I realize this isn't quite standard HTML with doctypes and all that, but for something this useless I don't think it's worth being precise ;)
proc htmlize {image_file save_to} { set page [open $save_to w] set source [image create photo -file $image_file] puts -nonewline $page {<html><head></head><body><table border=0 cellspacing=0 cellpadding=0>} foreach row [$source data] { puts -nonewline $page {<tr>} foreach color $row { puts -nonewline $page "<td width=1 height=1 bgcolor=$color></td>" } puts -nonewline $page {</tr>} } puts -nonewline $page {</table></body></html>} close $page }