Page 1 of 1

Adding text to images.. confused..

Posted: 2013-03-08T09:51:24-07:00
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?

Re: Adding text to images.. confused..

Posted: 2013-03-08T10:03:18-07:00
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'

Re: Adding text to images.. confused..

Posted: 2013-03-17T18:45:03-07:00
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