2

考虑这个例子(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

这给出了以下图像:

红蓝.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 是这样的(点击查看完整图片):

出.png

...所以澄清一下 - 我想知道它是否可以在获得的图块内移动图像montage tile 1x

4

2 回答 2

2

在 ImageMagick 6 中,另一种方法是扩展透明背景,然后在扩展图像下半部分的中心合成蓝色图像。

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


在此处输入图像描述

于 2019-01-18T20:09:49.497 回答
2

正如评论中所建议的:

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

在此处输入图像描述

于 2019-01-18T20:23:09.800 回答