I need some help writing a bash script to invoke a command line program to do batch processing. What I want to do is to invoke a command line program called enfuse, which combines multiple images of varying exposure into one image.

Enfuse is invoked by typing this into a terminal:

enfuse [options] [input files]

If I want to enfuse, say, 2 images (0000.jpg and 0001.jpg) together, with an output file of A0001.jpg I would type in

enfuse -o A0001.jpg 0000.jpg 0001.jpg

However, this is not what I want to do. I have a folder of images where the images are named sequentially (say, 0000.jpg, 0001.jpg...1000.jpg), where I want to enfuse multiple brackets of images, and each bracket consits of 2 images (0001.jpg & 0002.jpg will be the first bracket, and 0003.jpg and 0004.jpg will be the second bracket and so on)

How might I write a script that invokes enfuse to run on all my images, 2 images at a time, with output names that are sequential (A0001.jpg, A0002.jpg...)? Enfuse can work with wildcards as input files, but I don't want the entire folder to be fused into one image, so I can't just put in *.jpg as the input files.

有帮助吗?

解决方案

You could try something like this:

for i in {0000..1100}; do enfuse -o A$i.jpg $(( 10#$i*2 )).jpg $(( 10#$i*2 +1 )).jpg; done

其他提示

I would use a script to make a script from a list of the pairs of file names like this:

ls *jpg | awk 'BEGIN{n=1}{a=z;b=$1;if(n==2){print "enfuse -o A"b" "a" "b ;n=0;} z=b;n++}'

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top