How to combine pairs of images to single images?

  1. Please see Format your code to make it more readable
  2. The way you used $index makes montage only use it as a target, meaning you did not specify the source files, so montage uses all the files it finds as source and explodes when you run out of RAM. Instead, if you refer to the ridiculously long documentation I linked to in my previous post, you should specify the source files first, and the target file last. So change:
for index in $(seq 1 2 10); do
    montage -adjoin -quality 100 -background none -geometry +0+0 $index.jpg
done

to

for i in {1..100..2}; do
    montage -quality 92 -background white -tile 2x1 -geometry +0+0 "${i}.jpg" "$((i+1)).jpg" "output_${i}-$((i+1)).jpg"
done

To help you understand the code:

1 Like