代码 -
convert -size 2000x1000 xc:none -gravity center \
-stroke yellow -pointsize 50 -font Courier-BoldOblique -strokewidth 3 -annotate +100+100 caption:'Conflict is the gadfly of thought. It stirs us to observation and memory. It instigates to invention. It shocks us out of sheeplike passivity, and sets us at noting and contriving' \
-blur 0x25 -level 0%,50% \
-fill white -stroke none -annotate +100+100 caption:'Conflict is the gadfly of thought. It stirs us to observation and memory. It instigates to invention. It shocks us out of sheeplike passivity, and sets us at noting and contriving' \
1.jpg +swap -gravity center -geometry +0-3 \
-composite Walpaperquote.jpg
输出 :
我的问题是:如何才能显示完整的文本?哪里出了问题?
提前感谢你的帮助!!尝试了很多方法,但就是搞不清楚如何正确设置!!而且我对 ImageMagick 还很陌生!!
答案1
解决方案是在输入文本中包含换行符。有几种方法可以做到这一点:
$'\n'
使用$'...\n...'
- 通过将字符串用 括起来$'...'
,启用转义序列 -\n
是换行符。请参阅这里获得更多转义序列。
caption=$'Conflict is the gadfly of thought.\nIt stirs us to observation and memory.\nIt instigates to invention.\nIt shocks us out of sheeplike passivity, and sets us at noting and contriving'
read -d ''
用于read -d ''
从标准输入中获取多行 -EOF
标记输入的结束。
read -d '' caption <<EOF
Conflict is the gadfly of thought.
It stirs us to observation and memory.
It instigates to invention.
It shocks us out of sheeplike passivity, and sets us at noting and contriving
EOF
多行变量
实际上可以在引号之间添加换行符,但是从可读性的角度来看我不喜欢这样做。
caption="Conflict is the gadfly of thought.
It stirs us to observation and memory.
It instigates to invention.
It shocks us out of sheeplike passivity, and sets us at noting and contriving"
用法
这随后可以用作以下参数convert
:
in_file='1.jpg'
out_file='Walpaperquote.jpg'
convert -size 2000x1000 xc:none -gravity center \
-stroke yellow -pointsize 50 -font Courier-BoldOblique -strokewidth 3 -annotate +100+100 "caption:${caption}" \
-blur 0x25 -level 0%,50% \
-fill white -stroke none -annotate +100+100 "caption:${caption}" \
"${in_file}" +swap -gravity center -geometry +0-3 \
-composite "${out_file}"
示例输出(裁剪) - 您仍然需要调整边界框的大小。