build-icon.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. # Part of Zombie Navigator
  3. # Copyright © 2015 Zombie Navigator Developers
  4. mylog () {
  5. echo "[`date`] $@" >&2
  6. }
  7. dir="`dirname "$0"`"
  8. dir="`cd "$dir"; cd .. ; pwd`"
  9. cd "$dir"
  10. PATH="$PATH:$dir/.deps/zopfli"
  11. # Look for RSVG
  12. if ! which rsvg-convert >/dev/null 2>&1 ; then
  13. mylog "Please install rsvg-convert somewhere in PATH"
  14. exit 1
  15. fi
  16. source="branding/icon.svg"
  17. targetSmall="src/icon~`date +%s`.png"
  18. targetLarge="src/icon64~`date +%s`.png"
  19. mylog "Building a small icon (48x48@2x)..."
  20. rsvg-convert -w 96 -h 96 "$source" > "$targetSmall"
  21. mylog "Building a large icon (64x64@2x)..."
  22. rsvg-convert -w 128 -h 128 "$source" > "$targetLarge"
  23. # Look for Zopfli PNG
  24. if which zopflipng >/dev/null 2>&1 ; then
  25. mylog "Optimizing the small icon..."
  26. zopflipng --iterations=500 --splitting=3 --filters=01234mepb --lossy_8bit --lossy_transparent "$targetSmall" "$targetSmall.tmp"
  27. mv -f "$targetSmall.tmp" "$targetSmall"
  28. mylog "Optimizing the large icon..."
  29. zopflipng --iterations=500 --splitting=3 --filters=01234mepb --lossy_8bit --lossy_transparent "$targetLarge" "$targetLarge.tmp"
  30. mv -f "$targetLarge.tmp" "$targetLarge"
  31. else
  32. mylog "zopflipng is not available in PATH..."
  33. fi
  34. mylog "Done?"
  35. # vim: ts=4 noet ai