build-icon.sh 1.2 KB

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