简体   繁体   English

Imagemagick蒙太奇中的尺寸变化

[英]Size variation in a Imagemagick montage

I try to have random space between my images in an Imagemagick montage. 我尝试在Imagemagick蒙太奇中的图像之间留出随机空间。
My original script is: 我的原始脚本是:

montage images/* -mode Concatenate -tile 12x -geometry +10+10 -background white tile.png

…and I need something like: …而且我需要类似的东西:

montage images/* -mode Concatenate -tile 12x -geometry +($RANDOM%200+0)+($RANDOM%200+0) -background white tile.png

Is this possible? 这可能吗?

The -geometry is only evaluated once at the start, so I don't think your intended approach is going to work. -geometry一开始只评估一次,所以我认为您打算使用的方法不会起作用。 You can either grab the 12 images and total up their widths plus 11 randomly sized gaps and then create a canvas big enough to lay your images out on, or make a bunch of spacer blocks to move your images right and down by random amounts. 您可以抓取12张图像并合计它们的宽度加上11个随机大小的间隙,然后创建一个足够大的画布以将您的图像放到上面,或者制作一堆间隔块以随机地上下移动图像。

So, this is a rough starting point of how you might build something up maybe... I know you don't want the background yellow, but I am setting it that way so you can see what I am doing. 因此,这是您可能如何构建某些东西的粗略起点。我知道您不希望背景变黄,但是我将其设置为这种方式,以便您可以看到我在做什么。 I am basically laying out a red, a green and a blue image in a horizontal strip, but adding randomly sized spacer blocks in and I have coloured these in varying shades of grey so you can see them. 我基本上是在水平条上布置红色,绿色和蓝色的图像,但是在其中添加了随机大小的间隔块,并且我用不同的灰色阴影对它们进行了着色,以便您可以看到它们。

convert -background yellow                   \
   red.png xc:gray20[100x100]                \
   \( xc:gray40[80x80] green.png -append \)  \
   xc:gray60[25x25]                          \
   \( xc:gray80[200x200] blue.png -append \) \
   +append  tile.png

在此处输入图片说明

Each time an image and a spacer appear together in parentheses, that is basically a spacer ABOVE the image with the image itself -appended BELOW. 每次图像和分隔符一起出现在括号中时,它基本上是图像-appended和图像本身- -appended下面。 Each time a spacer occurs on its own, that is basically to the right of the preceding image, and at the end, the +append joins all the blocks up side-by-side. 每次间隔出现时,基本上是在前一个图像的右侧,最后, +append将所有块并排在一起。

To understand what I am doing, you need to appreciate that -append places images top-to-bottom, one above the other and that +append places images side-by-side next to each other. 要了解我在做什么,您需要欣赏-append将图像从上到下,一个放在另一个之上,以及+append将图像并排放置在一起。

I am suggesting you create a script to build the command up. 我建议您创建一个脚本来构建命令。

Basically, you could make a strip like this, then another one of 12 and use -append to stick them together. 基本上,您可以像这样制作一条条,然后再做成12条,然后使用-append将它们粘在一起。 Obvioulsy you want to make the background, and all the spacers, white. 您想使背景变暗,并且所有间隔物都变成白色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM