Skip to content
Advertisement

What is text syntax in ImageMagick

I use following code convert text to image

JavaScript

what is x, y means in text x, y ‘string’?

Advertisement

Answer

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:

JavaScript

enter image description here

Method 2 -annotate

Or, you can use -annotate to write onto an outsize canvas, then -trim the canvas back to the minimum afterwards:

JavaScript

enter image description here

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:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement