Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text on image at specific point using imagemagick

Tags:

imagemagick

I want to add text on an image at specific point and want it be centre aligned. How can I specify to margin from top? I want to specify margin in pixels/inches from top.

Currently I am using this command:

 convert temp.jpg -gravity Center  -pointsize 30 -annotate 0 'Love you mom' temp1.jpg  

it is writing text in centre of image. I want text to move to top.

This is what I am getting: enter image description here

This is what i want: enter image description here

like image 618
waqas Avatar asked Apr 23 '14 06:04

waqas


2 Answers

Try using -gravity North (this will move your text to the top of the image) and then adding an offset (-annotate +0+100) to move down your text:

convert temp.jpg -gravity North -pointsize 30 -annotate +0+100 'Love you mom' temp1.jpg  
like image 175
Andrea Avatar answered Sep 30 '22 19:09

Andrea


Instead, you can use -draw to specify the location you want your text.

For example:

convert -font helvetica -fill white -pointsize 60 -gravity center -draw "text 0,300 'TEXT TO BE DISPLAYED'" /image_address/Image_input.png /image_address/Image_output.png  

In this case, 0 is de x coordinate and 300 is the y coordinate, however the x coordinate is not really important since the -gravity center is already there.

Remember that the coordinate 0,0 is the top left corner.

like image 45
Matheus Torquato Avatar answered Sep 30 '22 21:09

Matheus Torquato