我正在制作一个快速的bash / imagemagick脚本
并将其置于最终图像中。
我可以将调整后的图像作为背景和文本的阴影放在顶部。但是,我还没有能够在阴影文本的顶部显示白色文本。
如何在单个imagemagick命令中实现所需的输出(并且没有gimp在打开结果图像时抱怨的PNG偏移量)?
代码:
#!/bin/bash
text="Beef meatball filet mignon, andouille biltong sausage kielbasa. Landjaeger pancetta shankle, ham hock beef corned beef kevin meatball beef ribs short ribs. Landjaeger biltong shoulder, salami brisket shank bresaola leberkas tail corned beef jowl ham pig. Venison pork loin capicola ham hock pastrami, turducken ground round prosciutto landjaeger bacon t-bone."
image="abstract-waves-on-a-blue-background.jpg"
width=1024
height=768
padding=100
text_width=$(( $width-$padding ))
text_height=$(( $height-$padding ))
convert \
-size "${text_width}x${text_height}" \
-background none \
-gravity center \
-fill white \
caption:"${text}" \
-background none \
-shadow 80x3+0+0 \
+repage \
\( \
"${image}" \
-resize "${width}x${height}^" \
-gravity center \
-crop "${width}x${height}+0+0" \
\) \
+swap \
-gravity center \
-composite \
"output.png"
答案 0 :(得分:1)
你非常亲密......我认为你需要这样的东西:
#!/bin/bash
text="Beef meatball filet mignon, andouille biltong sausage kielbasa. Landjaeger pancetta shankle, ham hock beef corned beef kevin meatball beef ribs short ribs. Landjaeger biltong shoulder, salami brisket shank bresaola leberkas tail corned beef jowl ham pig. Venison pork loin capicola ham hock pastrami, turducken ground round prosciutto landjaeger bacon t-bone."
image="bg.png"
width=1024
height=768
padding=100
text_width=$(( $width-$padding ))
text_height=$(( $height-$padding ))
convert \
-size "${text_width}x${text_height}" \
-background none \
-gravity center \
-fill white \
caption:"${text}" \( +clone -shadow 80x3+0+0 \) +swap -layers merge \
+repage \
\( \
"${image}" \
-resize "${width}x${height}^" \
-gravity center \
-crop "${width}x${height}+0+0" \
\) \
+swap \
-gravity center \
-composite +repage \
"output.png"