Image Magick - 将文本转换为图像 - 有没有办法将文本居中到图像的中间? [英] Image Magick - Converting text to image - is there a way to center the text to the middle of the image?
本文介绍了Image Magick - 将文本转换为图像 - 有没有办法将文本居中到图像的中间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的文本文件,其内容类似于今天是28度。我正在尝试使用imagemagick将其居中到图像的中间位置。我正在使用的命令就是这个
I have a simple text file that reads something like "It is 28 degrees today" I am trying to use imagemagick to center it to the middle of the image. The command i am using is this right now
`convert -background lightblue -fill blue -size 165x70 filename.txt image.png`
我尝试使用重力,但由于某种原因它总是把文字放在图像之外。我没有正确使用它。我希望它集中在一起。有什么建议吗?
I tried using gravity but it always put the text outside of the image for some reason. I am not using it correctly from what I can see. I would like it to be centered. Any suggestions?
推荐答案
convert \
-size 165x70 \
xc:lightblue \
-font Bookman-DemiItalic \
-pointsize 12 \
-fill blue \
-gravity center \
-draw "text 0,0 'It is 28 degrees today'" \
image.png
如果您想从现有文件中提取输入,只需将其输入到绘图命令:
If you want to pull the input from an existing file, just feed that to the draw command:
convert \
-size 165x70 \
xc:lightblue \
-font Bookman-DemiItalic \
-pointsize 12 \
-fill blue \
-gravity center \
-draw "text 0,0 '$(cat file.txt)'" \
image.png
这篇关于Image Magick - 将文本转换为图像 - 有没有办法将文本居中到图像的中间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文