MegaBites-AI/Windows-powershell
0372
1#!/usr/bin/env bash2 3lowercase(){4 echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"5}6 7display_usage() {8 echo9 echo " Usage: ./$(basename $0) svgfilename icnsfilename"10 echo11}12 13# Verify two arguments are passed.14if [ $# != 2 ];then15 display_usage16 exit 117fi18 19# Verify input SVG exists.20if [ ! -f $1 ]; then21 echo "SVG file not found."22 display_usage23 exit 124fi25 26# Verifiying OS as iconutil is needed."27if [ $(lowercase $(uname)) != "darwin" ]; then28 echo "Unsupported platform. Please run under macOS."29 exit 130fi31 32# Verify librsvg is installed.33if ! hash rsvg-convert 2>/dev/null; then34 echo "librsvg is not installed."35 exit 136fi37 38# Create temporary folder for iconset.39guid=$(uuidgen)40if ! mkdir $guid.iconset >/dev/null 2>&1; then41 echo "Error creating temporary iconset folder."42 exit 143fi44 45# Generate images for iconset.46rsvg-convert -f png -w 16 -h 16 -o $guid.iconset/icon_16x16.png $147rsvg-convert -f png -w 32 -h 32 -o $guid.iconset/icon_16x16@2x.png $148rsvg-convert -f png -w 32 -h 32 -o $guid.iconset/icon_32x32.png $149rsvg-convert -f png -w 64 -h 64 -o $guid.iconset/icon_32x32@2x.png $150rsvg-convert -f png -w 128 -h 128 -o $guid.iconset/icon_128x128.png $151rsvg-convert -f png -w 256 -h 256 -o $guid.iconset/icon_128x128@2x.png $152rsvg-convert -f png -w 256 -h 256 -o $guid.iconset/icon_256x256.png $153rsvg-convert -f png -w 512 -h 512 -o $guid.iconset/icon_256x256@2x.png $154rsvg-convert -f png -w 512 -h 512 -o $guid.iconset/icon_512x512.png $155rsvg-convert -f png -w 1024 -h 1024 -o $guid.iconset/icon_512x512@2x.png $156 57# Convert iconset to icns.58if ! iconutil -c icns $guid.iconset >/dev/null 2>&1; then59 echo "Error converting iconset to icns."60 exit 161fi62 63# Remove temporary folder.64if ! rm -rf $guid.iconset >/dev/null 2>&1; then65 echo "Error removing temporary iconset folder."66 exit 167fi68 69# Rename/Move icns file.70if ! mv $guid.icns $2 >/dev/null 2>&1; then71 echo "Error moving icns file."72 exit 173fi74exit 075 76 