I’m currently using this command to resize images using imagemagick:
convert \( ${files[0]} ${files[1]} -append \) \( ${files[2]} ${files[3]} -append \) +append $dir.jpg

What is the best way to deal with images which dimensions differ like in the second picture? can I specify specific width or height and make the image resize and crop to that size if its smaller and crop the center if its really hight so I always get the result like in first picture?
Thanks!
Try to resize the image to the same size.
Now you can append images.
Appending images before resizing
Appending images after resizing