如何使用ImageMagick在图像上绘制多个覆盖矩形
我使用以下代码在另一个图像上绘制覆盖框如何使用ImageMagick在图像上绘制多个覆盖矩形,imagemagick,draw,Imagemagick,Draw,我使用以下代码在另一个图像上绘制覆盖框 convert \ -background '#0002' \ -gravity Center \ -fill white \ -size ${page_width}x30 \ caption:"" \ "${img}"
convert \
-background '#0002' \
-gravity Center \
-fill white \
-size ${page_width}x30 \
caption:"" \
"${img}" \
+swap \
-geometry +0+100 \
-composite \
"${img}"
但是,我想在多个位置上绘制它,例如从图像的顶部到底部每隔100个像素绘制一次。
为此,我可以使用循环,但我想知道是否有更好的命令或解决方案解决此问题?您可以使用Imagemagick将图案平铺在图像上
- 使用-size创建“#0002”图像。。。xc:#0002”
- 以类似方式创建间距高度的完全透明图像
- 垂直附加两个图像
- 将它们平铺到输入图像的大小上
- 在输入图像上合成
结果:
# Line 1: read the input
# Line 2: create the tile (spacing set to 50 in transparent section)
# Line 3: tile it out over the size of the input by replacing it on the input
# Line 4: do the composite
# Line 5: save the output
convert lena.png \
\( -size 256x30 xc:"#0002" -size 256x50 xc:none -append -write mpr:tile +delete \) \
\( -clone 0 -tile mpr:tile -draw "color 0,0 reset" \) \
-compose over -composite \
result.png