问题描述
考虑以下示例(Ubuntu 18.04,ImageMagick 6.9.7-4 Q16 x86_64 20170114):
Consider this example (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
这给出了以下图像:
我想做的是将蓝色方块在其图块内"移动到任意x位置;例如,将蓝色正方形的左边缘对齐到红色矩形宽度的25%或50%处,或者甚至将蓝色正方形的右边缘与红色矩形的右边对齐.
What I'd like to do, is move the blue square on arbitrary x position "within its tile"; say align left edge of blue square to where 25% of the red rectangle width would be, or at 50% - or even align right edge of blue square with right edge of red rectangle.
我已经看到-tile-offset
存在( https://imagemagick.org/script/command-line-options.php#tile-offset ),而我在此示例中进行了尝试,但看起来并没有执行任何操作.
I have seen that -tile-offset
exists (https://imagemagick.org/script/command-line-options.php#tile-offset), and I've tried it with this example, but it doesn't look like it does anything.
如何在ImageMagick蒙太奇图像的一部分内移动图像?
How can I move an image, part of a ImageMagick montage, within its tile?
看起来-tile-offset
只能为显式图块图像指定(不是-tile 1x
,而是-tile red.png
),并且:
it looks like -tile-offset
can only be specified for explicit tile images (not as in -tile 1x
, but as in -tile red.png
), and:
在具有偏移量的背景上平铺较小的图像? -ImageMagick
这是一个例子:
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(单击以查看完整图像):
then out.png is this (click for full image):
...以便澄清-我想知道是否可以像在montage
tile 1x
... so to clarify - I'd like to know is its possible to move an image within a tile as obtained in montage
tile 1x
推荐答案
如注释中所建议:
convert -background none red.png \( -size 25x xc:none blue.png +append \) -append result.png
或具有2个不同的偏移量:
Or with 2 different offsets:
convert -background none red.png \
\( -size 25x xc:none blue.png +append \) \
\( -size 50x xc:none blue.png +append \) \
-append result.png
不确定最终目标是什么,但是您也可以执行以下操作:
Not sure what your end-goal is, but you can also do this:
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
这篇关于Imagemagick-在平铺的蒙太奇中移动/偏移图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!