On Tue, 1 Jan 2002 23:03:42 EST, [EMAIL PROTECTED] wrote:

>The problem? After I created a working script where it creates 'button.png'
>and views it, I try to add text to it, and no changes take affect. Without 
>that one line that adds text (Or should) the script is perfect. I don't want 
>it changed...anyway, that's the dilema, and here is the code:
>
>#!/usr/bin/perl
>use Image::Magick;
>#binmode STDOUT;
>print "Content-type: image/png\n\n";
>my($image);
>$image = Image::Magick->new;
>$image->Set(size=>'200x50', font=>'Generic.ttf', text=>"Hello, JOEL!", 
>pointsize=>10, stroke=>'red', fill=>'red', x=>100, y=>50); # this is one line
>$image->ReadImage('xc:blue');
>$image->Quantize(colorspace=>'grey');
>$image->Crop(geometry=>'100x100"+1"0+20');
>$image->Write(filename=>'button.png', compression=>'None');
>binmode STDOUT;
>$image->Write('png:-')
>
>As you see, the 7th line from the top which starts as
>$image Set(size ...) is not kicking in
>
>How do I keep this script, but add text to it without fail? This is funny 
>situation because the png's can be made and changed, and viewed, but when 
>text is added, it's useless. I can't grasp why. 

Hi, I played with it, and it seems your lines are out of order, so
the $image->ReadImage('xc:blue'); was overwriting everything with
a blank slate.
I also found that the text should be added in an Annotate method,
instead of throwing it all in the Set.
Finally, you need the "Generic.ttf" file in the directory your script runs.
I found it in the demos for the Perl-magick module.
This runs, but the point size needs adjusting, and your cropping
may be off.

Try this:

#!/usr/bin/perl
use Image::Magick;
print "Content-type: image/png\n\n";
my($image);
$image = Image::Magick->new;
$image->Set(size=>'200x50');
$image->ReadImage('xc:blue');
$image->Annotate( font=>'Generic.ttf', text=>"Hello, JOEL!", 
pointsize=>10, stroke=>'red', fill=>'red', x=>100, y=>50); # this is one line
$image->Quantize(colorspace=>'grey');
$image->Crop(geometry=>'100x100"+1"0+20');
$image->Write(filename=>'button.png', compression=>'None');
binmode STDOUT;
$image->Write('png:-')


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

Reply via email to