Center Text On Image

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
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Center Text On Image

Post by agriz »

Hi

I want to center the text on Image (Horizontal Center)
But the vertical position of the text will be in various place.

How do i do that?

Thanks
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Center Text On Image

Post by Bonzo »

I would use -gravity center to center it then move it up and dow - you do not say how you are writting the text as unsing -annotate you could -annotate +0+100 with -gravity
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Center Text On Image

Post by agriz »

I thought we can't use annotate while using gravity center.

Can i use negative values in annotate?

Thanks
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Center Text On Image

Post by Bonzo »

I am lost with the gravity business but think it should work in this situation BUT the text you are writting may be centered. Just try it and see - yes you can use negative values for -annotate
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Center Text On Image

Post by agriz »

Yes, It is working... :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Center Text On Image

Post by anthony »

as the vertical location is variable I would use 'North' gravity for horizontal centering then Y offset for vertical placement (specifying the gap between text and top of image).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply