Diego Venturi
Diego Venturi

Reputation: 41

ImageMagick - Cropping, resizing and joining two pictures

I need to add these two images: Picture 1 and Picture 2

in some way like this (done manually):

Montage

In fact, in the last picture, the two rectangles should have the same size, and the whole picture could be resized croping out the blank parts (no, I don't know how to do that even with gimp =p).

Since I have a lot of pictures, I am trying to do some kind of script, maybe with ImageMagick "montage".

I will run it in Ubuntu 14.04.

Upvotes: 0

Views: 148

Answers (1)

Diego Venturi
Diego Venturi

Reputation: 41

Got it!

#!/bin/bash

for i in $( seq 1 229 ); #I have 229 pictures 

do printf "%03d\t" "$i";
j=`printf "%03d\t" "$i"` ;

name1=`printf "anim.0%.3s.png" "$j"`;
output1=`printf "anOF%.3s.png" "$j"`;
name2=`printf "AnimationFrame000%.3s.jpg" "$j"`;
output2=`printf "anF%.3s.png" "$j"`;
final=`printf "output%.3s.png" "$j"`;

convert "$name1" -gravity Center -crop 1990x100-3-245 "$output1"
convert "$name2" -gravity Center -crop 1980x100+0+0 "$output2"
montage -geometry +1+1 "$output1" "$output2" -tile 1x2 "$final"

done

avconv -r 10 -i output%03d.png video.mp4

rm anOF* anF* output*

Upvotes: 1

Related Questions