dan wrote:
Hi all, again!

I'm attempting to make a web page, where all the buttons are dynamic, where
dynamic I say there's 1 "template" button image with nothing written on it,
and I want to put requests into a html page to call a script as an image to
put text on top of the image, then output as 1 image. Does this make sense
what I'm try to do? Is this even possible? If so, what's the best way of
going about it, as I have absolutely no idea where to start on this one.
I've aquired Apache::ImageMagick, but can't make head nor tail of the
readme.

To give you a start, this is a script I created a while back to create uniform buttons for a website I was working on.


#!/usr/bin/perl

use strict;
use warnings;

use GD;

my $im = new GD::Image(61,20);
my ($text, $saveto) = @ARGV;

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,$text);
# Use above dimensions to center text
$im->stringFT($black,"/somedir/arialnb.ttf",9,0,((57-$bounds[2])/2),13,$text);

open IMAGE, "> $saveto" or die "Can't open $saveto\n";
binmode IMAGE;
print IMAGE $im->png;
close IMAGE;

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to