render-asset.sh
    
    Bourne-Again shell script, ASCII text executable
        
            1
            #!/bin/bash 
        
            2
            set -ueo pipefail 
        
            3
             
        
            4
            FORCE_INKSCAPE="$(echo "${FORCE_INKSCAPE-False}" | tr '[:upper:]' '[:lower:]')" 
        
            5
            if [[ "${FORCE_INKSCAPE}" == "true" ]]; then 
        
            6
              RENDER_SVG="" 
        
            7
            else 
        
            8
              RENDER_SVG="$(command -v rendersvg)" || true 
        
            9
            fi 
        
            10
            INKSCAPE="$(command -v inkscape)" || true 
        
            11
            OPTIPNG="$(command -v optipng)" || true 
        
            12
             
        
            13
            if [[ -n "${INKSCAPE}" ]]; then 
        
            14
              if "$INKSCAPE" --help | grep -e "--export-filename" > /dev/null; then 
        
            15
                EXPORT_FILE_OPTION="--export-filename" 
        
            16
              elif "$INKSCAPE" --help | grep -e "--export-file" > /dev/null; then 
        
            17
                EXPORT_FILE_OPTION="--export-file" 
        
            18
              elif "$INKSCAPE" --help | grep -e "--export-png" > /dev/null; then 
        
            19
                EXPORT_FILE_OPTION="--export-png" 
        
            20
              fi 
        
            21
            fi 
        
            22
             
        
            23
            SRC_FILE="assets.svg" 
        
            24
            ASSETS_DIR="assets" 
        
            25
             
        
            26
            i="$1" 
        
            27
             
        
            28
            echo "Rendering '$ASSETS_DIR/$i.png'" 
        
            29
             
        
            30
            if [[ -n "${RENDER_SVG}" ]]; then 
        
            31
              "$RENDER_SVG" --export-id "$i" \ 
        
            32
                            "$SRC_FILE" "$ASSETS_DIR/$i.png" 
        
            33
            else 
        
            34
              "$INKSCAPE" --export-id="$i" \ 
        
            35
                          --export-id-only \ 
        
            36
                          "$EXPORT_FILE_OPTION=$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null 
        
            37
            fi 
        
            38
             
        
            39
            if [[ -n "${OPTIPNG}" ]]; then 
        
            40
              "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png" 
        
            41
            fi 
        
            42
             
        
            43
            echo "Rendering '$ASSETS_DIR/$i@2.png'" 
        
            44
             
        
            45
            if [[ -n "${RENDER_SVG}" ]]; then 
        
            46
              # @TODO: remove --zoom when it will be fixed/implemented in resvg 
        
            47
              "$RENDER_SVG" --export-id "$i" \ 
        
            48
                            --dpi 192 \ 
        
            49
                            --zoom 2 \ 
        
            50
                            "$SRC_FILE" "$ASSETS_DIR/$i@2.png" 
        
            51
            else 
        
            52
              "$INKSCAPE" --export-id="$i" \ 
        
            53
                          --export-id-only \ 
        
            54
                          --export-dpi=192 \ 
        
            55
                          "$EXPORT_FILE_OPTION=$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null 
        
            56
            fi 
        
            57
             
        
            58
            if [[ -n "${OPTIPNG}" ]]; then 
        
            59
              "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png" 
        
            60
            fi 
        
            61