ImageMagick中的文本语法是什么 [英] What is text syntax in ImageMagick

查看:135
本文介绍了ImageMagick中的文本语法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码将文本转换为图像

I use following code convert text to image

convert -size 1000x100 xc:transparent -pointsize 30 -draw "text 0,30 'Text'" /tmp/test.png

什么是x,y表示文字x ,y'string'?

what is x, y means in text x, y 'string'?

推荐答案

方法1 标签:

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:

convert -background yellow label:"This is some\nmulti-line text\nwhich\nsurprisingly enough -\nspans multiple lines" image.png

方法2 -annotate

Method 2 -annotate

或者,您可以使用 -annotate 来编写在超大画布上,然后 -trim 画布回到最小值:

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

convert -size 1000x1000 xc:blue -pointsize 30 -gravity northwest -annotate 0 'Text\nwith multiple\nlines.' -trim result.png

使用时 - 注释,请务必指定 -gravity ,以便根据文本的边界框进行定位,因为如果不这样做,它将会定位根据文字的基线(左下角)。

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.

方法3 标题:

Method 3 caption:

或者,你可以使用标题:,它会根据你提供的方框调整文本大小:

Or, you can use caption: which will size the text to best fit the box you provide:

convert -background pink -fill white -size 400x100 caption:"Here is a bunch of text that will be sized to best fit the box as far as is possible" result.png

这篇关于ImageMagick中的文本语法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆