Page 1 of 1

How do you use Annotate in PerlMagick? a 10-line script

Posted: 2007-02-13T12:16:36-07:00
by tdan
This script produces a 1pixel blank image:

Code: Select all

#!/usr/bin/perl
use Image::Magick;
use strict;

my $image = new Image::Magick;
$image->ReadImage( 'xc:none' );
$image->Set( size => '500x500' );
$image->Annotate( text=>'This is a cool line of text', font=>'arial.ttf', fill=>'blue', pointsize=>'12', geometry=>'+0+14' );
$image->Write( '__TextOut.png' )
I put arial.ttf in the same directory as the script.

Any thoughts?

Re: How do you use Annotate in PerlMagick? a 10-line script

Posted: 2007-02-13T12:27:40-07:00
by magick
Set the image size *before* you call ReadImage().

Re: How do you use Annotate in PerlMagick? a 10-line script

Posted: 2007-02-13T12:41:08-07:00
by tdan
Ah yes - that did it.

Re: How do you use Annotate in PerlMagick? a 10-line script

Posted: 2007-02-13T16:23:09-07:00
by tdan
OK, the text is printing but the following parameters don't do anything for me:
stretch - tried Condensed, UltraCondensed, Expanded...
style - tried Italic and Oblique
weight - tried different integers

I tried this with the Times font also.
Here's a sample script:

Code: Select all

#!/usr/bin/perl
use Image::Magick;
use strict;

my $image = new Image::Magick;
$image->Set( size => '500x500' );
$image->ReadImage( 'xc:none' );
$image->Annotate( text=>'This is a cool line of text\nHCB rocks\nLook 3 lines!', font=>'arial.ttf', fill=>'blue', pointsize=>'36', gravity=>'North', stretch=>10, style=>'Oblique', weight=>10 );
$image->Trim();
$image->Write( '__TextOut.png' )

Re: How do you use Annotate in PerlMagick? a 10-line script

Posted: 2007-02-13T19:06:48-07:00
by magick
Stretch, style, and weight are used to identify a font from the ImageMagick font list. However, you specified a particular font (arial.ttf) so no search is made.

Re: How do you use Annotate in PerlMagick? a 10-line script

Posted: 2010-07-29T02:07:06-07:00
by Ximer
And... how simulate oblique/italic font style?

I need this with font specified... example.. arial in italic...

thanks.

Re: How do you use Annotate in PerlMagick? a 10-line script

Posted: 2010-08-01T21:10:21-07:00
by anthony
You use a italic TTF file AlialItalic.ttf for example. Alrial has a whole family of font files.

however for oblique (or slanted) you can also use the annotate angle options. to angle the y axis by a few degrees.