Bash 在指定的框imagemagick中垂直居中但不水平居中文本

Bash 在指定的框imagemagick中垂直居中但不水平居中文本,bash,imagemagick,image-manipulation,imagemagick-convert,Bash,Imagemagick,Image Manipulation,Imagemagick Convert,我正在尝试从文本生成图像。要求:文本左对齐,垂直居中,尽可能大,最大分辨率1920x1080 这就是我所拥有的: convert -background white -fill black \ -font "fonts/DejaVuSansMono.ttf" \ -size 1920x1080 label:'Text \nloooooooooooooooooooooooooong text\nand another' \ -gravity West image.png 它工作得很好,但它不能垂

我正在尝试从文本生成图像。要求:文本左对齐,垂直居中,尽可能大,最大分辨率1920x1080

这就是我所拥有的:

convert -background white -fill black \
-font "fonts/DejaVuSansMono.ttf" \
-size 1920x1080 label:'Text \nloooooooooooooooooooooooooong text\nand another' \
-gravity West image.png
它工作得很好,但它不能垂直居中

看起来像这样:

但我希望它看起来像这样:


我可以使用-size x1080,并使用第二个命令将该图像置于空白白色图像的中心,但这不能确保它不是太宽。

在创建标签之前尝试设置重力

convert -background white -fill black -size 1920x1080 \
   -gravity west \
   label:'Text \nloooooooooooooooooooooooooong text\nand another' \
   image.png

编辑添加:当一个设置应该影响一个特定的操作时,在几乎所有使用ImageMagick的情况下,该设置都应该在操作之前。IM版本6在这方面有点宽容,但与您的示例一样,命令的顺序通常很重要。IM版本7要严格得多。

谢谢,这是一种问题,当有人马上知道答案时,我会花上几天的时间找出答案。这很简单。令人惊叹的再次感谢。