Este script deve fazer o que você quiser. Usa a largura máxima ou a altura máxima das imagens ao aparar.
# !/bin/bash
set -eu
gettrimbox() {
# Some lines were based on the code of Fred Weinhaus available on http://www.fmwconcepts.com/imagemagick/autotrim/
trimbox=$(convert "$1" -fuzz 35% -format "%@" info: | tr -cs "0-9\n" " ")
r_w=$(echo $trimbox | cut -d\ -f1)
r_h=$(echo $trimbox | cut -d\ -f2)
r_xoff=$(echo $trimbox | cut -d\ -f3)
r_yoff=$(echo $trimbox | cut -d\ -f4)
r_xcenter=$(((r_w/2)+r_xoff))
r_ycenter=$(((r_h/2)+r_yoff))
r_w=$((r_w+50))
r_h=$((r_h+50))
}
f1=$1
f2=$2
number1=$(echo "$f1" | tr -dc "0-9")
gettrimbox "$f1"
w1=$r_w; h1=$r_h
xcenter1=$r_xcenter; ycenter1=$r_ycenter
gettrimbox "$f2"
w2=$r_w; h2=$r_h
xcenter2=$r_xcenter; ycenter2=$r_ycenter
if [ $w1 -gt $w2 ]; then max_w=$w1; else max_w=$w2; fi
if [ $h1 -gt $h2 ]; then max_h=$h1; else max_h=$h2; fi
convert "$f1"[$max_w"x"$h1+$((xcenter1-(max_w/2)))+$((ycenter1-(h1/2)))] \
"$f2"[$max_w"x"$h2+$((xcenter2-(max_w/2)))+$((ycenter2-(h2/2)))] \
-append +repage "_MG_$number1-vmerged.jpg"
convert "$f1"[$w1"x"$max_h+$((xcenter1-(w1/2)))+$((ycenter1-(max_h/2)))] \
"$f2"[$w2"x"$max_h+$((xcenter2-(w2/2)))+$((ycenter2-(max_h/2)))] \
+append +repage "_MG_$number1-hmerged.jpg"