[英]How can I draw multiple overlay rectangles on an image using ImageMagick
我使用以下代碼在另一個圖像上繪制一個覆蓋框
convert \
-background '#0002' \
-gravity Center \
-fill white \
-size ${page_width}x30 \
caption:"" \
"${img}" \
+swap \
-geometry +0+100 \
-composite \
"${img}"
但是,我想在多個位置繪制它,例如從圖像的頂部到底部每隔 100 個像素。 我可以為此目的使用循環,但我想知道是否有更好的命令或解決方案來解決這個問題?
您可以通過使用 Imagemagick 將您的圖案平鋪在圖像上來做到這一點。
輸入:
# 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
結果:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.