
function write_to_img() {

   #echo "addtext.sh: write_to_img() arguments: " $1 $2 $3 $4;
   # e.g. 500 -20+25 ./barbie3.png ./tmp.png

   width=`identify -format %w $3`; \
   convert -background '#0005' -fill '#FFFFFF' -gravity center -size ${width}x40 \
          caption:"`sed -n $1p phrases.txt`" -font /usr/share/fonts/extra/Quicksand_Bold.otf \
          $3 +swap -gravity North -composite $4 


}

cp ./phrases.txt /tmp
cp ./*barbie*png /tmp
cd /tmp
p=$1
#echo panel: $p
i=barbie$(($RANDOM%5)).png
#echo img: $i 
r=$2
#echo line: $r
write_to_img $r '-25+25' ./$i ./panel$p.png

exit 0


