簡體   English   中英

Imagemagick-在平鋪的蒙太奇中移動/偏移圖像?

[英]Imagemagick - move/offset images within a tiled montage?

考慮以下示例(Ubuntu 18.04,ImageMagick 6.9.7-4 Q16 x86_64 20170114):

convert -size 300x100 xc:red red.png
convert -size 100x100 xc:blue blue.png
montage red.png blue.png -frame 5 -geometry '+0+0' -tile 1x redblue.png

這給出了以下圖像:

redblue.png

我想做的是將藍色方塊“在其圖塊內”移動到任意x位置; 例如,將藍色正方形的左邊緣對齊到紅色矩形寬度的25%或50%的位置-甚至將藍色正方形的右邊緣與紅色矩形的右邊對齊。

我已經看到了-tile-offset存在( https://imagemagick.org/script/command-line-options.php#tile-offset ),並且我已經在此示例中進行了嘗試,但是它看起來並不像它會做任何事情。

如何在ImageMagick蒙太奇圖像的一部分內移動圖像?


編輯:看起來-tile-offset只能為顯式圖塊圖像指定(不是-tile 1x ,而是-tile red.png ),並且:

在具有偏移的背景上平鋪較小的圖像? -ImageMagick

-tile-offset必須在平鋪之前。 它表示單個全局偏移量,而不是拼貼的間距。

這是一個例子:

convert -size 300x100 radial-gradient:\#400-\#FAA red.png
convert -size 500x500 xc: -tile-offset +100+40 +size -tile red.png  -border 5 -geometry +5+5  -draw "color 0,0 reset" out.png

然后是out.png(單擊查看完整圖像):

out.png

...以便澄清-我想知道是否有可能像montage tile 1x一樣在tile 1x內移動圖像

在ImageMagick 6中,另一種方法是擴展透明背景,然后在擴展圖像下半部分的中心合成藍色圖像。

convert -size 300x100 xc:red -background none -extent 300x200 -size 100x100 xc:blue -geometry +100+100 -composite result.png


在此處輸入圖片說明

如評論中所建議:

convert -background none red.png \( -size 25x xc:none blue.png +append \) -append result.png

在此處輸入圖片說明

或具有2個不同的偏移量:

convert -background none red.png            \
   \( -size 25x xc:none blue.png +append \) \
   \( -size 50x xc:none blue.png +append \) \
   -append result.png

在此處輸入圖片說明

不確定最終目標是什么,但是您也可以執行以下操作:

convert -gravity east -background none red.png blue.png red.png blue.png -append result.png

在此處輸入圖片說明

或這個:

convert -gravity center -background none red.png blue.png red.png blue.png -append result.png

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM