I want to add some words into image using image::magick, the code is below:
#!/usr/bin/perl -w
use Image::Magick;
$im = Image::Magick->new(size => '1300x5000');
$im->Read('xc:white');
$im->Set(stroke => 'red');
$im->Draw(primitive => 'rectangle',points => '0,0 399,299');
$text = 'Works like magick!';
$im->Annotate(font=>'times.ttf', pointsize=>40, fill=>'green', text=>$text);
$im->Write('png:GDExample.png');
the code is running well and even I can see the retangle on the image, but I can`t find the words!
Could you help me?
Thanks a lot
Can`t write words into image
Re: Can`t write words into image
My guess is that since you didn't define x or y parameters, the text is being drawn at 0,0. Since the origin of a text annotation is at the bottom left (assuming text is left justified), this puts it off the screen. Try setting x and y to positive integers and see if that fixes it.
Example:
Example:
Code: Select all
$im->Annotate(font=>'times.ttf', pointsize=>40, fill=>'green', text=>$text, x=>10, y=>50);