Page 1 of 1

Positioning of text with Annotate()

Posted: 2014-10-19T21:44:09-07:00
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;

Re: Positioning of text with Annotate()

Posted: 2014-10-20T10:44:19-07:00
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.

Re: Positioning of text with Annotate()

Posted: 2014-10-22T11:30:58-07:00
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.