在指定的框 imagemagick 中垂直居中但不水平居中文本
Center text vertically but not horizontally in specified box imagemagick
我正在尝试从文本生成图像。要求是:文本左对齐、垂直居中、尽可能大、最大。分辨率 1920x1080.
这是我的:
convert -background white -fill black \
-font "fonts/DejaVuSansMono.ttf" \
-size 1920x1080 label:'Text \nloooooooooooooooooooooooooong text\nand another' \
-gravity West image.png
效果很好,但不能垂直居中。
看起来像这样:
https://imgur.com/rJLxJO2.png
但我希望它看起来像这样:https://imgur.com/IVrydty.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 更加严格。
我正在尝试从文本生成图像。要求是:文本左对齐、垂直居中、尽可能大、最大。分辨率 1920x1080.
这是我的:
convert -background white -fill black \
-font "fonts/DejaVuSansMono.ttf" \
-size 1920x1080 label:'Text \nloooooooooooooooooooooooooong text\nand another' \
-gravity West image.png
效果很好,但不能垂直居中。
看起来像这样: https://imgur.com/rJLxJO2.png
但我希望它看起来像这样:https://imgur.com/IVrydty.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 更加严格。