Guest User

Untitled

a guest
Feb 3rd, 2018
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #!/bin/bash
  2. set -eu
  3.  
  4. readonly INKSCAPE_PATH=/Applications/Inkscape.app/Contents/Resources/bin/inkscape
  5.  
  6. if [ $# -lt 1 ]; then
  7. >&2 echo "usage: $0 <svg-file-path>"
  8. exit 1
  9. fi
  10.  
  11. PNG_PATH=${1%.*}
  12. echo "export to $PNG_PATH"
  13.  
  14. if [ ! -f "$INKSCAPE_PATH" ]; then
  15. >&2 echo "inkscape not found: $INKSCAPE_PATH"
  16. exit 1
  17. fi
  18.  
  19. if [ ! -f "$1" ]; then
  20. >&2 echo "file not found: $1"
  21. exit 1
  22. fi
  23.  
  24. mkdir -p "$PNG_PATH"
  25. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-20.png" --export-width=20 --export-height=20
  26. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-20@2x.png" --export-width=40 --export-height=40
  27. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-20@3x.png" --export-width=80 --export-height=80
  28. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-29.png" --export-width=29 --export-height=29
  29. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-29@2x.png" --export-width=58 --export-height=58
  30. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-29@3x.png" --export-width=87 --export-height=87
  31. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-40.png" --export-width=40 --export-height=40
  32. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-40@2x.png" --export-width=80 --export-height=80
  33. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-40@3x.png" --export-width=120 --export-height=120
  34. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-60@2x.png" --export-width=120 --export-height=120
  35. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-60@3x.png" --export-width=180 --export-height=180
  36. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-76.png" --export-width=76 --export-height=76
  37. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-76@2x.png" --export-width=152 --export-height=152
  38. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-83.5@2x.png" --export-width=167 --export-height=167
  39. $INKSCAPE_PATH --file="$1" --export-png="$PNG_PATH/icon-1024.5@2x.png" --export-width=1024 --export-height=1024
  40.  
  41. echo done
Add Comment
Please, Sign In to add comment