Get dimensions to insert text when image box dimensions are known

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
weareborg
Posts: 1
Joined: 2018-08-27T02:20:07-07:00
Authentication code: 1152

Get dimensions to insert text when image box dimensions are known

Post by weareborg »

Hello friends,

We are working on adding some text dynamically in the image. Our designers will allocate a box inside each image and give us the dimensions, location of the box as shown in the image below. I tried to add text, but the X and Y axis required are very different from the ones provided by our design team. How can I add text in an image with dimensions and location based upon Pixels. Image height and width is known in pixels. Thank you.

Image

Command used :

Code: Select all

convert output.png -gravity West -pointsize 30 -annotate +120+225 'my crazy cat' output.jpg 
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Get dimensions to insert text when image box dimensions are known

Post by snibgo »

You have "-gravity West", so the starting point for "-annotate" offsets is half-way down the left side. It seems more sensible to have "-gravity NorthWest" to start from the top-left corner, or perhaps SouthWest to start from bottom-left.
snibgo's IM pages: im.snibgo.com
Post Reply