Fly*_*ngV 3 text imagemagick transparent box
这是在现有图片上绘制TRANSPARENT黄色框的代码.我在文档中添加了"Merry Xmas Mom and Dad"文本.挑战在于:如何在我刚刚创建的Box中自动调整我的'Merry Xmas Mom and Dad'?
如果我的文字改为"我爱你的妈妈和爸爸"怎么办?任何基于文本维度的"硬编码值"都必须重做.
转换funny-santa.jpg -strokewidth 0 -fill"rgba(255,215,0,0.5)"-draw"rectangle 0,0 1024,350"-pointsize 30 -fill black -annotate + 67 + 60' Merry Christmas Mom和爸爸'output.jpg
您也可以从15个月前看看我的答案:
如果使用正确的方法,文本将自动适合.让我们使用宽270像素,高70像素的盒子.这是我使用的命令,首先是一个简短的文字:
mytext="Cheers\!"
convert \
-background '#0008' \
-gravity center \
-fill white \
-size 260x70 caption:"${mytext}" \
funny-santa.jpg \
+swap \
-gravity south \
-composite \
funny-santa---1.jpg
Run Code Online (Sandbox Code Playgroud)
结果如下(原始图像在顶部,图像底部有文字):

如果您想将更长的文本放入同一个框中,只需使用更长的文本:-)
看这里:
mytext="Dear Kids\! One day you'll learn everything about Santa Claus. On that day, please also remember what they told you about Jesus."
convert \
-background '#0008' \
-gravity center \
-fill white \
-size 260x70 caption:"${mytext}" \
funny-santa.jpg \
+swap \
-gravity south \
-composite \
funny-santa---2.jpg
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
1334 次 |
| 最近记录: |