Adding text to images.. confused..

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
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Adding text to images.. confused..

Post by dognose »

I've been using IM for a long time to draw text on images, usually in the form: -fill '#ffffff' -pointsize 20 -draw "rotate 45 text 100,100 'This is text'"

I've been having trouble with special characters and unicode, so, I thought I could just put the text in a file and access with @filename,
but that doesn't seem to work with -draw

Looking at the text examples here: http://www.imagemagick.org/Usage/text
there are a lot of options for drawing text, but each seems not support all the features? (like position)

So, I'm wondering what's draw the text.. should I just use draw and programmatically escape all the special characters?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adding text to images.. confused..

Post by snibgo »

Yeah, we are spoilt for choice, but it is confusing.

You can put the entire draw argument in a text file, eg ...

Code: Select all

"%IMG%convert" -size 500x500 xc: -draw @draw.txt d.png
... where draw.txt contains ...

Code: Select all

rotate 45 text 100,100 'This is text'
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Adding text to images.. confused..

Post by anthony »

You can also use -annotate with @filename argument method.
This has no extra quotes to deal with and when reading from a file the text is literal, so no further escapes.
You can specify size and offset for the text placement.


See Annotate
http://www.imagemagick.org/Usage/text/#annotate
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply