# -coalesce makes sure that each individual frame is complete
convert animated.gif -coalesce frame%05d.png
# compose and flatten frames
for x in frame*.png; do convert -page +0+0 base.png -page +200+10 $x -flatten +repage comp-`basename $x`; done
# get frame delays
identify -verbose animated.gif |grep Delay|sed 's/.* \([0-9]*\)x.*/\1/' > delays
# generate convert command from the delays
$( echo -n convert; i=0; for d in `cat delays`; do printf " -delay $d comp-frame000%02d.png " $i; let i++; done; echo " out.gif" )