dan wrote:
Well, I had a feeling it *might* have been HTML related, but I knew perl had some image manipulation modules, and I was just wondering if there was anything that could create images for me on-the-fly, rather than go through complicated HTML routines each time I wanted to create an image with some custom text on it. Rather than go through complicated HTML routines, I thought it might be easier to make an <img src="customimage.pl?text=whatever+i+want"> etc.. where the text to put in is
One word of caution, do somehtign to make sure people can't create spuriouse maliciouse buttons:
Here is an image form dan's site: [img src="http://dan.com/customimage.pl?text=your+mother+uses+windows" /]
or what I've done before is encrypt any text I want inro a string and use that in my url
custimg.pl?text=qlbdchjqbsdcjhlqwbdecljhqwbedlkcjhqwbefhjbqwhe
it unencrypts it and display's the real text, that allows you to not have to keep track of the allowed text inside the script, but it does make itr a bit more complex :)
generated by the script creating the html for the page, if that makes sense?
try this modified version of Andrew's suggestion:
#!/usr/bin/perl
use strict; use warnings;
use GD; use CGI qw(header param);
my $im = new GD::Image(61,20);
my %phrases = ( 1 => 'Home', 2 => 'Contact', 3 => 'Foo bar Baz', ); my $text = param('text'); $text = 1 unless exists $phrases{$text};
my $white = $im->colorAllocate(255,255,255); my $black = $im->colorAllocate(0,0,0); my $gray = $im->colorAllocate(132,132,132); my $blue = $im->colorAllocate(206,206,255); my $leftblue = $im->colorAllocate(231,231,255); my $bottomblue = $im->colorAllocate(165,165,206); my $rightblue = $im->colorAllocate(123,123,156); my $topblue = $im->colorAllocate(214,214,255);
$im->transparent($white);
$im->interlaced('true');
$im->filledRectangle(0,0,60,19,$white);
$im->filledRectangle(3,3,60,19,$gray);
$im->filledRectangle(0,0,57,16,$blue);
$im->rectangle(0,0,57,16,$white);
$im->line(1,0,56,0,$topblue);
$im->line(57,1,57,15,$rightblue);
$im->line(1,16,56,16,$bottomblue);
$im->line(0,1,0,15,$leftblue);
# Dry run to determine size of outputted text
my @bounds = GD::Image->stringFT($black,"/somedir/arialnb.ttf",9,0,0,0,$phrases{$text});
# Use above dimensions to center text
$im->stringFT($black,"/somedir/arialnb.ttf",9,0,((57-$bounds[2])/2),13,$phrases{$text});
# out put to browser print header('image/png'); print $im->png;
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>