[FW]: This code performs the rather esoteric function of converting an image file to a raw HTML page,
using a
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 {}
foreach row [$source data] {
puts -nonewline $page {}
foreach color $row {
puts -nonewline $page " | "
}
puts -nonewline $page {
}
}
puts -nonewline $page {
}
close $page
}
'''Feedback: meh''': Found it quite useful in [CGI] scripts for human verification.
Stops them just matching the image filename to a set of corresponding characters - with some modification, random parts of the image can be modified to further deter non-human usage. Good work :)
[FW]: Thanks. It happens that the more accepted way to achieve the first effect is by using a second script that sends through the appropriate image file (or generates one). To alter random parts or otherwise custom generate [CAPTCHA]s you can use the image tools directly.
[Sarnold]: You may gain bandwidth (I guess that would help) by generating all this HTML code with [Javascript].
It may be something like :
function line(row) {
var i;
// increment by steps 6 because the color is stored in 6 characters
for (i=0;i");
}
}
function nextline() {document.write("");}
then, in your HTML body, just append:
----
[[
[Category Graphics] -
[Category Image Processing]
]]