notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

svg_to_icns.sh (1299B)


      1 #!/bin/bash
      2 
      3 # Exit on error
      4 set -e
      5 
      6 # Check dependencies
      7 if ! command -v inkscape &> /dev/null; then
      8     echo "Error: Inkscape is required but not installed. Install it and try again."
      9     exit 1
     10 fi
     11 
     12 if ! command -v iconutil &> /dev/null; then
     13     echo "Error: iconutil is required but not installed. This tool is available only on macOS."
     14     exit 1
     15 fi
     16 
     17 # Check input arguments
     18 if [ "$#" -ne 2 ]; then
     19     echo "Usage: $0 input.svg output.icns"
     20     exit 1
     21 fi
     22 
     23 INPUT_SVG=$1
     24 OUTPUT_ICNS=$2
     25 TEMP_DIR=$(mktemp -d)
     26 
     27 # Create the iconset directory
     28 ICONSET_DIR="$TEMP_DIR/icon.iconset"
     29 mkdir "$ICONSET_DIR"
     30 
     31 # Define sizes and export PNGs
     32 SIZES=(
     33     "16 icon_16x16.png"
     34     "32 icon_16x16@2x.png"
     35     "32 icon_32x32.png"
     36     "64 icon_32x32@2x.png"
     37     "128 icon_128x128.png"
     38     "256 icon_128x128@2x.png"
     39     "256 icon_256x256.png"
     40     "512 icon_256x256@2x.png"
     41     "512 icon_512x512.png"
     42     "1024 icon_512x512@2x.png"
     43 )
     44 
     45 echo "Converting SVG to PNGs..."
     46 for size_entry in "${SIZES[@]}"; do
     47     size=${size_entry%% *}
     48     filename=${size_entry#* }
     49     inkscape -w $size -h $size "$INPUT_SVG" -o "$ICONSET_DIR/$filename"
     50 done
     51 
     52 # Convert to ICNS
     53 echo "Generating ICNS file..."
     54 iconutil -c icns -o "$OUTPUT_ICNS" "$ICONSET_DIR"
     55 
     56 # Clean up
     57 rm -rf "$TEMP_DIR"
     58 
     59 echo "Done! ICNS file saved to $OUTPUT_ICNS"