Positioning of text with Annotate()

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
danmc
Posts: 8
Joined: 2014-09-08T18:18:38-07:00
Authentication code: 6789

Positioning of text with Annotate()

Post by danmc »

I'm using Annotate() to add some text on top of an image. Things mostly work but I want the text to be about 1/2 an inch (150 pixels in my case) above the bottom edge of the image instead of right at the bottom edge. I have tried translate=> "0,150" but that didn't seem to move the text at all. Any suggestions?

Code: Select all

    my $x = $image->Annotate(
                       undercolor=>'transparent',
                       font=>"myfont.ttf",
                       pointsize=> 48,
                       fill=>'black',
                       gravity=>'South',
                       translate=> "0,150",
                       text=>"Page #2");
   warn "$x" if $x;
danmc
Posts: 8
Joined: 2014-09-08T18:18:38-07:00
Authentication code: 6789

Re: Positioning of text with Annotate()

Post by danmc »

I should have included the version:

$ convert --version
Version: ImageMagick 6.7.6-3 2013-10-12 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

As near as I can tell, the "translate=>" part doesn't do anything at all.
danmc
Posts: 8
Joined: 2014-09-08T18:18:38-07:00
Authentication code: 6789

Re: Positioning of text with Annotate()

Post by danmc »

Looks like what I needed was

y=>150,

to move the text north by 150 pixels from bottom center so:

Code: Select all

	

     my $x = $image->Annotate(
                           undercolor=>'transparent',
                           font=>"myfont.ttf",
                           pointsize=> 48,
                           fill=>'black',
                           gravity=>'South',
                           y=> 150,
                           text=>"Page #2");
       warn "$x" if $x;


Hope this helps someone else.
Post Reply