anything-scripts

Disposable scripts to fix day to day problems.
git clone git://soucy.cc/anything-scripts.git
Log | Files | Refs

svg-optim.sh (648B)


      1 #!/usr/bin/env bash
      2 
      3 # Find SVGs then pipes to svgo
      4 # find . -type f -name "*.svg" | svg-optim
      5 # ls "*.svg" | svg-optim
      6 # echo "ico.svg" | svg-optim
      7 
      8 if hash svgo 2>/dev/null; then
      9     # Get the path to this script
     10     thisDir="$(dirname "$(readlink -f "$0")")"
     11     svgoconf="$thisDir/.svgoconf.yml"
     12 
     13     while read -r pathtosvg; do
     14         # Test if mime type is SVG
     15         if [[ $(file -b --mime-type "$pathtosvg") == "image/svg"* ]]; then
     16             svgo "$pathtosvg" --config="$svgoconf" --output="${pathtosvg%.*}.optim.svg"
     17         fi
     18     done
     19 else
     20     echo "- Sorry, But You must Install *svgo*:"
     21     echo "- 'sudo npm install -g svgo'"
     22 fi