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(solved)
Can`t write words into image(solved)
Last edited by tujchl1223 on 2008-09-03T18:15:01-07:00, edited 1 time in total.
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Can`t write words into image
I think you need to specify a coordinate to Annotate. It is probably defaulting to 0,0 which is the top left of the image and most text won't be visible because it is drawn above the baseline.
As a starting point, try adding
x=>50, y=>50,
to the Annotate call.
Pete
As a starting point, try adding
x=>50, y=>50,
to the Annotate call.
Pete
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Can`t write words into image
Or set gravity to something else but none. For example NorthWest
is NOT the same as none, generally Center is good.
is NOT the same as none, generally Center is good.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Can`t write words into image
it works!
Thank you but the most important things in annotate method ,I think, is to specify the type of characters. the code will not work even you set up everything but it.
tujchl
Thank you but the most important things in annotate method ,I think, is to specify the type of characters. the code will not work even you set up everything but it.
tujchl
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Can`t write words into image
What do you mean by "type of characters"?tujchl1223 wrote:it works!
Thank you but the most important things in annotate method ,I think, is to specify the type of characters. the code will not work even you set up everything but it.
tujchl
The font?
Actually I think all the settings are all important, so as to get the desired result.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/