#!/bin/sh --

for i in pngtopnm pnmscale pnmtopng
do
  which $i >/dev/null 2>/dev/null
  if test $? = 1; then
    me=`basename $PWD`
    echo "*******************************************************************************"
    echo
    echo "\"$i\" not found."
    echo "This means it will not be possible to create/complete this iconset, \"$me\"."
    echo "If you don't care, ignore this message, otherwise, read on."
    echo
    echo "Possible reasons:"
    echo "- you don't have the netpbm package"
    echo "- netpbm is old or incomplete"
    echo "- netpbm binaries are in a directory not in PATH"
    echo
    echo "Possible fix:"
    echo "- Install a recent netpbm and make sure the binaries are found."
    echo
    echo "*******************************************************************************"
    exit
  fi
done

HERE=$PWD

cd ../tosh_128
cp mime.icons $HERE 2>/dev/null
cp README?* $HERE 2>/dev/null

mask=$HERE/mask

echo "MASK IS $mask"

for i in *.png
do
  pngtopnm -alpha $i|pnmscale -r 2 > $mask
  pngtopnm $i|pnmscale -r 2|pnmtopng -alpha $mask > $HERE/$i
done

rm $mask

cd $HERE

for i in _*.png
do
  j=`echo $i|cut -c 2-`
  echo "Overriding $j..."
  cp $i $j
done
