How to push text label down

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

How to push text label down

Post by robocop »

Hi Folks, Hope someone could help me please :)

With the following command:

Code: Select all

convert -background white -fill '#FF6961' -stroke '#FF6961'  -font times.ttf \
          -size 500x500  -pointsize 300   -gravity center \
          label:W    sample.jpg
I get the following image which appears center:
Image

I'm trying to push the text a bit down so it would appear something like this:
Image

I'm not using the -gravity south feature as I need it at an exact position. I also tried the padding feature but it added more pixels to the image canvas size. I do need the canvas size to remain the same.

Using ImageMagick 6.7.7-10

Any help is greatly appreciated!

Thank you
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to push text label down

Post by Bonzo »

You can use -geometry +0+0 on its own to set the distance from the top left corner or use it with -gravity to adjust it from there.

Although it may not work with label: depending the effect yoU are after can you use -annotate ?
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: How to push text label down

Post by 246246 »

Bonzo wrote:You can use -geometry +0+0 on its own to set the distance from the top left corner or use it with -gravity to adjust it from there.

Although it may not work with label: depending the effect yoU are after can you use -annotate ?
-extent seems to work for label; you have to use negative y value to move down.

Code: Select all

convert -background white -fill '#FF6961' -stroke '#FF6961'  -font '/Library/Fonts/Times New Roman.ttf' -size 500x500  -pointsize 300 -gravity center -extent +0-50 label:W show:
Edit:
To modify to correct order by snibgo's suggestion just below:

Code: Select all

convert -background white -fill '#FF6961' -stroke '#FF6961'  -font '/Library/Fonts/Times New Roman.ttf' -size 500x500  -pointsize 300 -gravity center label:W -extent +0-50 show:
Last edited by 246246 on 2015-09-07T06:16:43-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to push text label down

Post by snibgo »

"-extent" is an image operation, not a setting. So it should be placed after the image has been created, not before.
snibgo's IM pages: im.snibgo.com
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: How to push text label down

Post by 246246 »

Thank you snibgo for correcting. (Currently it works even at the very first position, probably for backward compatibility.)
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: How to push text label down

Post by robocop »

246246 wrote:
Bonzo wrote:You can use -geometry +0+0 on its own to set the distance from the top left corner or use it with -gravity to adjust it from there.

Although it may not work with label: depending the effect yoU are after can you use -annotate ?
-extent seems to work for label; you have to use negative y value to move down.

Code: Select all

convert -background white -fill '#FF6961' -stroke '#FF6961'  -font '/Library/Fonts/Times New Roman.ttf' -size 500x500  -pointsize 300 -gravity center -extent +0-50 label:W show:
Thank you so much! The code worked perfect with the -extent suggestion you gave. This will save me a great deal of time :) Thanks again!
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: How to push text label down

Post by robocop »

Bonzo wrote:You can use -geometry +0+0 on its own to set the distance from the top left corner or use it with -gravity to adjust it from there.

Although it may not work with label: depending the effect yoU are after can you use -annotate ?
I did try both of them with not much luck, however the -extent operation given by 246246 did the trick.

Thanks again for your help and suggestions! Appreciate it!
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to push text label down

Post by fmw42 »

Another solution is just to use -roll, if you have enough padding.

Code: Select all

convert -background white -fill '#FF6961' -stroke '#FF6961'  -font '/Library/Fonts/Times New Roman.ttf' -size 500x500  -pointsize 300 label:W -roll +0+50 show:
see
http://www.imagemagick.org/script/comma ... s.php#roll
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: How to push text label down

Post by robocop »

fmw42 wrote:Another solution is just to use -roll, if you have enough padding.

Code: Select all

convert -background white -fill '#FF6961' -stroke '#FF6961'  -font '/Library/Fonts/Times New Roman.ttf' -size 500x500  -pointsize 300 label:W -roll +0+50 show:
see
http://www.imagemagick.org/script/comma ... s.php#roll
Yes this works great as well! Both the solutions do the trick :)

Thanks for your help. Much appreciated! Cheers
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
Post Reply