Drawing outlined text with Annotate: Parameter trouble

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
mr fuzzy

Drawing outlined text with Annotate: Parameter trouble

Post by mr fuzzy »

I am trying to create outlined text and have run into trouble using Annotate(). I am running on Ubuntu 6.06 with imageMagick 6.3.4 (as reported by convert).

I have tried setting the strokewidth to a large number, I've also tried setting the weight to Bold but annotate doesn't seem to make any use of these parameters.

I have tried several other things but nothing works so far. I get the feeling that Annotate() doesn't implement several of the parameters documented at http://www.imagemagick.org/script/perl-magick.php. Is there a better source for perlmagick documentation anywhere? Any help would be gratefully recieved.

A code snipit for what I've tried:

Code: Select all

# Try writing in bold behind the normal text
$error = $image->Annotate(
	fill      => black,
	pointsize => 45,
	text      => "Test",
	weight    => Bold,     
	x         => 50,
	y         => 50,
);
print "-> $error\n";

# Try writing with a wide stroke
# for the stylish red outline
$error = $image->Annotate(
	fill        => blue,
	pointsize   => 45,
	text        => "Test",
	StrokeWidth => 5,
	Stroke      => red,
	x           => 50,
	y           => 50,
);
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Drawing outlined text with Annotate: Parameter trouble

Post by magick »

The ImageMagick source distribution comes with an example outline text script. Download it and take a look at ImageMagick-6.3.5/PerlMagick/demo/shadow_text.pl.
mr fuzzy

Re: Drawing outlined text with Annotate: Parameter trouble

Post by mr fuzzy »

Thanks for the tip, I had a look at the script, it was a great example of how to do an elegant drop shadow but I can't figgure out how to make it outline the text. I'm trying to get something like http://tbn0.google.com/images?q=tbn:XQx ... -title.png (image of outlined text "Mozilla").

Again, any help appreciated
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Drawing outlined text with Annotate: Parameter trouble

Post by magick »

Next up take a look at this tutorial: http://www.imagemagick.org/Usage/fonts/.
mr fuzzy

Re: Drawing outlined text with Annotate: Parameter trouble

Post by mr fuzzy »

Thanks for the directions, I've got it working now.

The problem was related to my setup. I didn't have FreeType installed properly.

For anyone else with a related problem, this is how I fixed it:

The hint was when I ran one of the annotate demos from the tutorial page I got the error:
convert: unable to read font `Garuda'.
convert: FreeType library is not available ........

I followed the instuctions from the post viewtopic.php?f=1&t=7177 subject: "Freetype missing ..." and installed freetype then recompiled ImageMagick.

I also had to replace the file:
/usr/local/lib/ImageMagick-6.3.4/config/type-ghostscript.xml

Which was pointing at the wrong place, with the file:
/usr/lib/ImageMagick-6.2.4/config/type-ghostscript.xml

After that everything started working perfectly, including the -stroke parameter.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Drawing outlined text with Annotate: Parameter trouble

Post by anthony »

rather than constantaly replacing the system file, you can create a personal 'type.xml' file in a '.magick' sub-directory of your home. See the top level page of IM Examples http://www.imagemagick.org/Usage/#fonts for one automated method of generating this file for your system.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
karenchu
Posts: 1
Joined: 2011-07-02T04:51:58-07:00
Authentication code: 8675308

Re: Drawing outlined text with Annotate: Parameter trouble

Post by karenchu »

hm, useful tip. never heard of such a way
Post Reply