#!/bin/bash
echo "quit" | /usr/bin/gs -q -sDEVICE=png256 -sOutputFile=/tmp/dump$$.png  $1 > /dev/null 2> /dev/null
#/usr/bin/convert /tmp/dump$$.png -crop 0x0  /tmp/dump1$$.png
# use only -crop 0x0 for miage-magic version 5 and below 
/usr/bin/convert /tmp/dump$$.png -trim  /tmp/dump1$$.png
/usr/bin/convert -border 15x15 -bordercolor white /tmp/dump1$$.png   $2
rm -f /tmp/dump$$.png /tmp/dump1$$.png

#echo "quit" | /usr/bin/gs -q -sDEVICE=png256 -sOutputFile=-   $1  2> /dev/null  | /usr/bin/convert -  -crop 0x0  - | /usr/bin/convert -border 15x15 -bordercolor white -  $2
