#!/bin/sh

function usage() {
  NAME=$(basename "$0")
  echo "Usage: ${NAME} <source-icon> <output-directory>"
}

IN_FILE="$1"
OUT_DIR="$2"

if [[ ! -r "$IN_FILE" ]]; then
  echo "Missing source icon, or file not found: $IN_FILE"
  usage
  exit 1
fi
if [[ ! -d "$OUT_DIR" ]]; then
  echo "Missing output directory, or directory not found: $OUT_DIR"
  usage
  exit 2
fi

for SIZE in 29 40 60 76 83.5; do
  PREFIX="${IN_FILE%.png}_$SIZE"
  echo "* Generating app icons at $SIZE points with filename prefix $PREFIX"
  retina-scale "$IN_FILE" "$OUT_DIR" "$PREFIX" $SIZE $SIZE
done
