#!/bin/bash

RESOURCE=`tempfile`
#ICON=`tempfile`
#BACKGROUND=`tempfile`

if [ -f "$1" ];
then
   if [ -x `which wrestool` -a -x `which icotool` ];
   then
      wrestool --extract --type=14 --output="${RESOURCE}" "${1}"
      icotool --extract $(icotool -l "${RESOURCE}" | head --lines=1) "${RESOURCE}" --output "${2}"
      #composite "${ICON}" -geometry 62x62+4+4 -gravity southeast "${BACKGROUND}" "${2}"
   fi

   rm -f "${RESOURCE}" "${ICON}" "${BACKGROUND}"
else
   echo "No such file!"
fi

exit 0

