简体   繁体   English

ImageMagick:如何将来自多个目录的多个图像与具有不同参数的蒙太奇组合在一起?

[英]ImageMagick: How to combine multiple images from multiple directories with Montage with different arguments?

I have multiple images distributed along different directories.我有多个图像分布在不同的目录中。

Each folder has different number of headers and side panels.每个文件夹都有不同数量的页眉和侧面板。 For this reason, the workaround is to execute montage function from imagemagick software with specific arguments for each temporal composed image .出于这个原因,解决方法是从imagemagick软件执行蒙太奇函数,并为每个时间合成图像提供特定参数。

Here a simple example:这里有一个简单的例子:

cd /home/archy && montage figure1/*.png -tile 2x -geometry +1+1 figure1.png

cd /home/archy && montage figure2/*.png -tile 1x -geometry +1+1 figure2.png

See that first temporal image is a composition of two columns of images.看到第一张时间图像是两列图像的组合。 On the other hand, the second temporal image is a composition of one column of images.另一方面,第二时间图像是一列图像的合成。 Finally, I need a final image composed by this two temporal images previously created.最后,我需要由之前创建的这两个时间图像组成的最终图像

cd /home/archy && montage *.png -tile 1x -geometry +1+1 total.png

In the real situation, I have to create a big amount of temporal images to only create the final one.在真实情况下,我必须创建大量时间图像才能创建最后一个。 It would be great to avoid this workaround to save calculus time and system storage.最好避免这种变通方法以节省微积分时间和系统存储。

Is it posible to combine this three commands to an unique one?是否可以将这三个命令组合成一个唯一的命令? Thanks谢谢

It's not that clear to me where all your files are, but I think I can assist you.我不太清楚你所有的文件在哪里,但我想我可以帮助你。 Rather than writing to a disk file, you can make any ImageMagick command write to a MIFF ( "Magick Image File Format" ) stream that will preserve all information that you might otherwise have written to a file.您可以将任何ImageMagick命令写入 MIFF( “Magick 图像文件格式” )流,而不是写入磁盘文件,该流将保留您可能已写入文件的所有信息。

So, you can do this without writing to disk:因此,您可以在不写入磁盘的情况下执行此操作:

montage SOMESTUFF SOMEHOW miff:- | convert miff:- OTHERSTUFF result.png

In your specific case, I think you want:在您的具体情况下,我认为您想要:

cd /home/archy
{ 
   montage figure1/*.png -tile 2x -geometry +1+1 miff:- 
   montage figure2/*.png -tile 1x -geometry +1+1 miff:-
} | montage miff:- -tile 1x -geometry +1+1 result.png

So, you are running your first montage the same as it ever was and writing that, followed by the result of your second montage in one compound statement, into a third montage command that receives the first two montage outputs and montages them into a final result!!!因此,您将montage运行第一个montage ,然后将其写入第三个montage命令,然后将第二个montage的结果写入一个复合语句中,该命令接收前两个montage输出并将它们蒙太奇生成最终结果!!!

I know what I mean, even if no-one else does!我知道我的意思,即使没有其他人知道!

By the way, if you want to run it as a one-liner, you will need an additional semi-colon before the closing brace and always a space either side of both braces:顺便说一句,如果你想将它作为单行运行,你需要在右大括号之前添加一个分号,并且两个大括号的两边总是一个空格:

{ montage figure1/*.png -tile 2x -geometry +1+1 miff:- ; montage figure2/*.png -tile 1x -geometry +1+1 miff:- ; } | montage miff:- -tile 1x -geometry +1+1 result.png

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

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