Adding text to an 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
rottmanj

Adding text to an image

Post by rottmanj »

I am working on a project where I need to add text to an image. I have the bulk of the work done, but I have run into a few stumbling points.

So far this is what I have

Code: Select all

convert -font helvetica -pointsize 9 -draw "text 167,554 'userName' text 145,596 'userTitle'" img1.jpg img1b.jpg
The issue I have having is that userName uses a 9pt font at 300 dpi and userTitle uses a 7pt font at 300dpi. When I run the command above, both items of text are at 9pt and 96 dpi. So how to I write it so that the first item of text is at 9pt 300 dpi and the second is at 7pt 300 dpi?

Any help with this is greatly appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adding text to an image

Post by fmw42 »

Typically, the proper syntax for convert is to have the input image right after the word "convert"

convert inputimage ...options... outputimage

I suspect all images are getting your options applied. Try the above and see if that helps.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Adding text to an image

Post by Bonzo »

No idea about the 300dpi part but this will give you 2 different font sizes:

Code: Select all

convert img1.jpg -font helvetica -pointsize 9 -draw "text 167,554 'userName'" -pointsize 7 -draw "text 145,596 'userTitle'" img1b.jpg
Post Reply