My thanks to all who responded. The solution turned out to be quite simple. I replaced the 2 'convert' commands at the end with this one.
convert $1 -alpha set -virtual-pixel transparent -distort Perspective "$exp" -background $pxl -| xv -