Re: Creating images

2004-06-29 Thread Randy W. Sims
dan wrote:
The only other issue I'd have, is it possible to change the
font of "Custom Text" to Tahoma? If so, how do it do it, and do I need any
additional files?
see `perldoc GD` : look for the 'stringFT' method
see also `perldoc GD::Text`
example:
$img->stringFT(
  $black, # color ref
  'path/too/tahoma.ttf', # absolute path to TTF
  12,# point size
  0  # rotation angle
  $x,$y,
  $string
);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Creating images

2004-06-29 Thread Randy W. Sims
dan wrote:
The only other issue I'd have, is it possible to change the
font of "Custom Text" to Tahoma? If so, how do it do it, and do I need any
additional files?
see `perldoc GD` : look for the 'stringFT' method
see also `perldoc GD::Text`
example:
$img->stringFT(
  $black, # color ref
  'path/too/tahoma.ttf', # absolute path to TTF
  12,# point size
  0  # rotation angle
  $x,$y,
  $string
);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Creating images

2004-06-29 Thread LRMK

LRMK
- Original Message - 
From: "dan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 29, 2004 3:33 AM
Subject: Re: Creating images


> This does exactly what I want, except I used the output code from
> JupiterHost.Net's suggestion, as i wanted to output straight to the
browser,
> not to a file. The only other issue I'd have, is it possible to change the
> font of "Custom Text" to Tahoma? If so, how do it do it, and do I need any
> additional files?
>
> Cheers, Dan
>
>
> "Randy W. Sims" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > On 6/25/2004 6:56 PM, 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.
> >
> > Try the GD module. I think it does what you want.
> >
> > (untested)
> >
> > use GD;
> >
> > my $img = GD::Image->newFromJpeg( $file );
> > my $black = $img->colorAllocate( 0, 0, 0 );
> > $img->string( gdSmallFont, 10, 10, 'Custom Text', $black );
> >
> ># open( FH, '>outfile' ) or die;
> > #binmode( FH );
> > #print FH $img->png();
> > #close( FH );
#To output to the browser use the following
method
print "Cache-Control: no-cache\n";#probably you will need this line
to stop browsing from caching your output
print "Content-Type: image/png\n\n";  #tell the browser and the server
what type of data that you are sending
binmode(STDOUT);
print $img->png();



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


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




Re: Creating images

2004-06-29 Thread dan
This does exactly what I want, except I used the output code from
JupiterHost.Net's suggestion, as i wanted to output straight to the browser,
not to a file. The only other issue I'd have, is it possible to change the
font of "Custom Text" to Tahoma? If so, how do it do it, and do I need any
additional files?

Cheers, Dan


"Randy W. Sims" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 6/25/2004 6:56 PM, 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.
>
> Try the GD module. I think it does what you want.
>
> (untested)
>
> use GD;
>
> my $img = GD::Image->newFromJpeg( $file );
> my $black = $img->colorAllocate( 0, 0, 0 );
> $img->string( gdSmallFont, 10, 10, 'Custom Text', $black );
>
> open( FH, '>outfile' ) or die;
> binmode( FH );
> print FH $img->png();
> close( FH );
>
> __END__
>
> Regards,
> Randy.
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Creating images

2004-06-28 Thread JupiterHost.Net

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  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]
 



Re: Creating images

2004-06-28 Thread dan
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  etc.. where the text to put in is
generated by the script creating the html for the page, if that makes sense?

Dan

"James Edward Gray II" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Jun 25, 2004, at 5:56 PM, 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.
>
> This sounds like a HTML (DHTML or CSS or whatever) question.  You would
> probably get better, quicker responses from a group that focus on those
> kinds of problems.
>
> James
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Creating images

2004-06-28 Thread Randy W. Sims
On 6/25/2004 6:56 PM, 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.
Try the GD module. I think it does what you want.
(untested)
use GD;
my $img = GD::Image->newFromJpeg( $file );
my $black = $img->colorAllocate( 0, 0, 0 );
$img->string( gdSmallFont, 10, 10, 'Custom Text', $black );
open( FH, '>outfile' ) or die;
binmode( FH );
print FH $img->png();
close( FH );
__END__
Regards,
Randy.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Creating images

2004-06-26 Thread Andrew Gaffney
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]
 



Re: Creating images

2004-06-26 Thread James Edward Gray II
On Jun 25, 2004, at 5:56 PM, 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.
This sounds like a HTML (DHTML or CSS or whatever) question.  You would 
probably get better, quicker responses from a group that focus on those 
kinds of problems.

James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Creating images

2004-06-26 Thread dan
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.

Any help much appreciated.

Dan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]