#!/bin/bash

P="@CMAKE_BINARY_DIR@"
sizes="512 256 128 64 48 32 22 16"

if [[ "$1" != "" ]]; then
P=$1
fi

for f in `find ${P} -name hisc*.svgz`; do
for size in $sizes; do
  fb=`basename $f`
  target=`echo $f | sed -e 's,/hisc-,/hi'${size}'-,g' | sed -e 's,svgz,png,g'`
  echo "Converting "${fb}" to size: " $size
  inkscape --without-gui --export-png=$target --export-dpi=72 --export-background-opacity=0 --export-width=$size --export-height=$size ${f} > /dev/null 2>&1
  rc=$?
  if [[ "$rc" = "0" ]]; then
  echo "    Done in "$target
  else
  echo "    FAILED"
  fi
done
done