#!/bin/sh
#
# converts a xpm to a png
# uses netpbm
#
# 11. June 2002
# Diether Knof

if [ $# == 0 ]; then
  > image.xpm
  file="image.xpm"
elif [ $# == 1 ]; then
  file=$1
else
  echo "Please give no more than one filename"
  exit 0;
fi

xpmtoppm --alphaout=- ${file} \
	> mask.pbm
xpmtoppm ${file} \
	| pnmtopng -alpha mask.pbm -background white \
	2> /dev/null

rm mask.pbm
if [ $# == 0 ]; then
  rm ${file}
fi