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?".
-gravity center will find the center of the image and you can offset it with -geometry +10+10
If you are using -annotate you can offset it in the -annotate command -annotate +10+10 "text"
If it was me I would write the text into a box with a transparent backgound ( caption or label ) then find the size of the box bounding the text and do some calculations on placing the text in the correct place.
You do not say how you are running the code but you may have to use fx for the calculations if you have no other way of doing the calculations.
Yes, But how can i center dynamic text with different number of characters?
ex : "This is funny", "booo", "hon", ...
If you write your text using -annotate with -gravity center, it will center the text at the offset location. At least that is my understanding. Thus it does not matter how long the text is, so long as it does not exceed your box size.
The same for label: and caption: if you create those images in center justified mode and then use -gravity center and -geometry to place them at the center of your box. The only computations from fx: would be to compute the box coordinates center relative and not top left relative.
agriz wrote:I can use -gravity and -annotate but what can i do if the text size is not same all the time?
I would generate a gravity centered 'caption:' of the appropriate size (with or without a pointsize), and then layer that caption on the background image. http://www.imagemagick.org/Usage/text/#caption