Question - I’m almost there but I can’t seem to get the for statement working as I want it to
This is what I had written
for index in $(seq 1 2 10)
do
montage -adjoin -quality 100 -background none -geometry +0+0 $index.jpg
done
Now what happens is that if there are more than 2 images, the combined image keeps on combining the other pairs so that it has 4 images combined, and then 8 and then 12 and keeps on getting bigger and bigger
As for the for statement, what you are currently doing is repeating the montage action and adding your output file in every next iteration. This will gobble up your memory and disk space fast. Instead, the image pairs should be replacing rose: and logo: in my example and the result filename should also be changing. My bash is a little rusty so I will let someone else help you with that.
PSmagick is IM7’s convert, so if you are using IM6, do
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
There was a formatting error, you have to format code here as preformatted text. I edited the post. Please try again. You have first to “cd” into the right directory.
Sorry, I wasn’t being clear. What you were doing was
1st iteration: Montage of Image 1 + 2
2nd iteration: Montage of Image 3 + 4 + Montage of Image 1 + 2
…
As you can see, things would get out of hand very quickly, resulting in memory and disk overload! I suggest that you test your commands/scripts using dummy images like rose: or logo: that are smaller in size and therefore quicker to process and detect your mistakes. I have generated some images for you to use while determining your workflow:
Edit #1: I zipped the files to make it easier to download: color_blocks.zip (764 Bytes).
So, my new command would be
for i in {1..100..2}; do
magick "${i}.png" "$((i+1)).png" +append "output_${i}-$((i+1)).jpg"
done
I am using Win7 ATM, so I will let you give the command a whirl.
Edit #2: I changed the first jpgs to pngs since that is what the color blocks are. If you are using tifs, then change them to tif, etc.