[ic] text as image/img src element

Michael Neilly mneilly at yahoo.com
Wed Jun 2 14:41:32 EDT 2004


I would like to create a "text as image" usertag that I can use on my
various pages as a security measure against automated scripts
submitting
forms. I see this on lots of pages these days where a random code is
presented as an image and the user must enter that code to submit the
form.

I would like to use the scratch space to store my parameters and code
to be used to generate the image... easy enough but.... is there a way
to make a reference through interchange that will execute tags but not
output its own header/html so I can use it as the src element in an img
tag?

<img src="/cgi-bin/mystore/text2image">

Where text2image wants to be something like the following:

[perl interpolate=1]

use GD;

my $img = new GD::Image(200,80);

my $white = $img->colorAllocate(255,255,255);
my $black = $img->colorAllocate(0,0,0);
my $red   = $img->colorAllocate(255,0,0);

$img->transparent('true');
$img->interlaced('true');

$img->rectangle(0,0,199,79,$white);
$img->string(gdSmallFont,10,10,"Text Test",$black);

print header('image/png');
print $img->png;

[/perl]

thanks in advance!
-M




More information about the interchange-users mailing list