Skip to content
Snippets Groups Projects
Select Git revision
  • 62756e34083d60c42554b463cd51966ce570ce75
  • master default protected
  • 101-upgrade-framework-and-dependencies
  • 84-improve-app-metadata
  • 82-fix-colors
  • 23-add-timer
  • 65-update-icons
  • Release_0.10.0_87 protected
  • Release_0.9.2_86 protected
  • Release_0.9.1_85 protected
  • Release_0.9.0_84 protected
  • Release_0.8.0_83 protected
  • Release_0.7.0_82 protected
  • Release_0.6.0_81 protected
  • Release_0.5.2_80 protected
  • Release_0.5.1_79 protected
  • Release_0.5.0_78 protected
  • Release_0.4.1_77 protected
  • Release_0.4.0_76 protected
  • Release_0.3.1_75 protected
  • Release_0.3.0_74 protected
  • Release_0.2.1_73 protected
  • Release_0.2.0_72 protected
  • Release_0.1.22_71 protected
  • Release_0.1.21_70 protected
  • Release_0.1.20_69 protected
  • Release_0.1.19_68 protected
27 results

build_icons.sh

Blame
  • build_icons.sh 1.58 KiB
    #! /bin/bash
    
    # Check dependencies
    command -v inkscape >/dev/null 2>&1 || { echo >&2 "I require inkscape but it's not installed. Aborting."; exit 1; }
    command -v scour >/dev/null 2>&1 || { echo >&2 "I require scour but it's not installed. Aborting."; exit 1; }
    command -v optipng >/dev/null 2>&1 || { echo >&2 "I require optipng but it's not installed. Aborting."; exit 1; }
    command -v convert >/dev/null 2>&1 || { echo >&2 "I require convert (imagemagick) but it's not installed. Aborting."; exit 1; }
    
    CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
    BASE_DIR="$(dirname "${CURRENT_DIR}")"
    
    SOURCE="${CURRENT_DIR}/icon.svg"
    OPTIPNG_OPTIONS="-preserve -quiet -o7"
    
    # optimize svg
    cp ${SOURCE} ${SOURCE}.tmp
    scour \
        --remove-descriptive-elements \
        --enable-id-stripping \
        --enable-viewboxing \
        --enable-comment-stripping \
        --nindent=4 \
        -i ${SOURCE}.tmp \
        -o ${SOURCE}
    rm ${SOURCE}.tmp
    
    # build icons
    function build_icon() {
      ICON_SIZE="$1"
      TARGET="$2"
    
      TARGET_PNG="${TARGET}.png"
    
      inkscape \
          --export-width=${ICON_SIZE} \
          --export-height=${ICON_SIZE} \
          --export-filename=${TARGET_PNG} \
          ${SOURCE}
    
      optipng ${OPTIPNG_OPTIONS} ${TARGET_PNG}
    }
    
    
    build_icon  72 ${BASE_DIR}/android/app/src/main/res/mipmap-hdpi/ic_launcher
    build_icon  48 ${BASE_DIR}/android/app/src/main/res/mipmap-mdpi/ic_launcher
    build_icon  96 ${BASE_DIR}/android/app/src/main/res/mipmap-xhdpi/ic_launcher
    build_icon 144 ${BASE_DIR}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher
    build_icon 192 ${BASE_DIR}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher