sibi kanagaraj
sibi kanagaraj

Reputation: 101

Merging Images Vertically in Multipe of 2

I have a situation where from a folder , I would like to merge 1 and 2 nd image vertically , 3rd and 4th Image vertically and so forth .

I have searched and found that Image magic does merging of images but not in any order . Is it possible to do it in Command Line .

Scenario: Files inside the folder 1.png , 2.png , 3.png upto say 60.png Expected Output : Merge 1.png and 2.png vertically stacked one below the other Merge 3.png and 4.png vertically stacked one below the other . SO that I would be having 30 images finally .

I am using Ubuntu.

Upvotes: 0

Views: 368

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207485

You can do it like this:

#!/bin/bash

out=0
for ((i=1;i<60;i+=2)); do
   ((j=i+1))
   ((out=out+1))
   A=${i}.png
   B=${j}.png
   echo Stacking $A and $B to make result-${out}.png
   magick "$A" "$B" -smush 10 "result-${out}.png"
done

Upvotes: 1

Related Questions