create-ico.sh 629 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. NC='\033[0m'
  3. RED='\033[0;31m'
  4. YELLOW='\033[0;33m'
  5. if [[ -z $1 ]]; then
  6. echo -e "${RED}You must include an SVG file to convert!${NC}"
  7. exit 1
  8. fi
  9. outfile=$2
  10. if [[ -z $outfile ]]; then
  11. outfile="logo.ico"
  12. fi
  13. if ! command -v inkscape &> /dev/null; then
  14. echo -e "${YELLOW}Could not find inkscape; $outfile not built!${NC}"
  15. exit 0
  16. fi
  17. echo "Generating $outfile from $1..."
  18. size_list=(16 24 32 48 64 128 256)
  19. for size in "${size_list[@]}"; do
  20. inkscape -z -e $size.png -w $size -h $size "$1" >/dev/null 2>/dev/null
  21. done
  22. images=$(printf "%s.png " "${size_list[@]}")
  23. convert $images $outfile
  24. rm $images