I use following code convert text to image
convert -size 1000x100 xc:transparent -pointsize 30 -draw "text 0,30 'Text'" /tmp/test.png
what is x, y means in text x, y 'string'?
I use following code convert text to image
convert -size 1000x100 xc:transparent -pointsize 30 -draw "text 0,30 'Text'" /tmp/test.png
what is x, y means in text x, y 'string'?
Method 1
label:
You can either use
label:
which provides a canvas large enough to hold your text - notice I didn't provide a canvas size:Method 2
-annotate
Or, you can use
-annotate
to write onto an outsize canvas, then-trim
the canvas back to the minimum afterwards:When using
-annotate
, be sure to specify-gravity
so that it positions according to the bounding box of your text, because if you do not, it will position according to the baseline (bottom-left corner) of your text.Method 3
caption:
Or, you can use
caption:
which will size the text to best fit the box you provide:In the ImageMagick "-draw text x,y string" option, "x,y" is the position of the bottom* left of the text measured from the the top left of the image. You can use the "-gravity" option to measure from other corners of the image, for example,
will place the lower left corner* of the text 30 pixels above the lower left corner of the image.
*strictly speaking, it's the left end of the baseline of the text; if there are symbols with descenders such as "g" or "y", those extend below the baseline. Demonstrate that with "-text 0,0 goody" and you'll just see the descenders extending into the top of the image.
produces