我正在尝试创建一个透明背景的png文件,其中我将图像放在一起。
到目前为止我的命令是:
convert --% -bordercolor none -background none -gravity center logo.png -border 5x5 ( img1.jpg img2.jpg img3.jpg -border 5x5 +append ) ( img4.jpg img5.jpg img6.jpg -border 5x5 +append ) -append -border 5x5 -resize 720x480 output.png
它创建了我的这个图像
如何更改命令以使图像显示如下?
(我把背景变成灰色,这样可以看到白色文字,后面的背景应该是透明的)
我试过Mark Setchells建议到目前为止这个命令看起来像这样:
convert -background none -bordercolor none -gravity west \ C:\xampp\htdocs\app\storage\images\Img_1.jpg label:"1" +swap -append label:"text 1" -append -write miff:- +delete \ C:\xampp\htdocs\app\storage\images\Img_2.jpg label:"2" +swap -append label:"text 2" -append -write miff:- +delete \ C:\xampp\htdocs\app\storage\images\Img_3.jpg label:"3" +swap -append label:"text 3" -append -write miff:- +delete \ C:\xampp\htdocs\app\storage\images\Img_4.jpg label:"4" +swap -append label:"text 4" -append -write miff:- +delete \ C:\xampp\htdocs\app\storage\images\Img_5.jpg label:"5" +swap -append label:"text 5" -append -write miff:- +delete \ C:\xampp\htdocs\app\storage\images\Img_6.jpg label:"6" +swap -append label:"text 6" -append miff:- | montage -set label '' miff:- -background pink -tile 3x2 -geometry +15+5 miff:- | convert -size 800x500 xc:gray80 -gravity center miff:- -composite -gravity north C:\xampp\htdocs\app\storage\images\logo.png -geometry +0+30 -composite C:\xampp\htdocs\app\storage\images\result.png
答案 0 :(得分:2)
你可以做很多事。这是一个:
#!/bin/bash
convert -background none -bordercolor none -gravity west \
\( 1.png label:"1" +swap -append label:"text 1" -append -border 5x5 \) \
\( 2.png label:"2" +swap -append label:"text 2" -append -border 5x5 \) +append \
\( 3.png label:"3" +swap -append label:"text 3" -append -border 5x5 \) +append \
\( \
\( 4.png label:"4" +swap -append label:"text 4" -append -border 5x5 \) \
\( 5.png label:"5" +swap -append label:"text 5" -append -border 5x5 \) +append \
\( 6.png label:"6" +swap -append label:"text 6" -append -border 5x5 \) +append \
\) -append \
-gravity center -extent 800x550 \
-gravity north logo.png -geometry +0+30 -composite result.png
通过这种方式,您可以使用第一个convert
命令将标签放在每个图像的上方和下方,然后将所有6个带标签的图像流式传输到montage
,以便为您执行网格布局(粉红色)从那里回到另一个convert
创建灰色背景画布并在顶部写下徽标。
#!/bin/bash
convert -background none -bordercolor none -gravity west \
1.png label:"1" +swap -append label:"text 1" -append -write miff:- +delete \
2.png label:"2" +swap -append label:"text 2" -append -write miff:- +delete \
3.png label:"3" +swap -append label:"text 3" -append -write miff:- +delete \
4.png label:"4" +swap -append label:"text 4" -append -write miff:- +delete \
5.png label:"5" +swap -append label:"text 5" -append -write miff:- +delete \
6.png label:"6" +swap -append label:"text 6" -append miff:- |
montage -set label '' miff:- -background pink -tile 3x2 -geometry +15+5 miff:- |
convert -size 800x500 xc:gray80 -gravity center miff:- -composite -gravity north logo.png -geometry +0+30 -composite result.png
抱歉,我不知道或理解为什么Windows在解析命令方面如此拙劣,但经过多次摆弄后,以下似乎有效 - 我不明白为什么!
convert -background none -bordercolor none -gravity west ^
1.png label:"1" +swap -append label:"text 1" -append -write miff:- +delete ^
2.png label:"2" +swap -append label:"text 2" -append -write miff:- +delete ^
3.png label:"3" +swap -append label:"text 3" -append -write miff:- +delete ^
4.png label:"4" +swap -append label:"text 4" -append -write miff:- +delete ^
5.png label:"5" +swap -append label:"text 5" -append -write miff:- +delete ^
6.png label:"6" +swap -append label:"text 6" -append miff:- | montage -set label "" miff:- ^
-background pink -tile 3x2 -geometry +15+5 miff:- | convert -size 800x500 ^
xc:gray80 -gravity center miff: -composite -gravity north logo.png -geometry +0+30 -composite result.png