gen-variants.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. # Generate favicon variants.
  3. # Requirements: bash, python3, imagemagick, optipng.
  4. set -euo pipefail
  5. COLOR_RED='#f44336'
  6. COLOR_YELLOW='#ff9800'
  7. COLOR_BLUE='#1b81e4'
  8. WIDTH=0.1875
  9. OFFSET=0.0625
  10. WIDTHS=(16 32)
  11. circle() {
  12. offset_abs=$(python3 -c "print(int($1 * $OFFSET))")
  13. x=$(python3 -c "print(int($1 - $1 * $WIDTH - $offset_abs))")
  14. xx=$(python3 -c "print(int($1 - $offset_abs))")
  15. y=$(python3 -c "print(int($1 * $WIDTH + $offset_abs))")
  16. echo "circle $x,$y $xx,$y"
  17. }
  18. for w in ${WIDTHS[@]}; do
  19. echo "Red ${w}x${w}"
  20. magick favicon-${w}x${w}.png \
  21. -fill $COLOR_RED \
  22. -draw "$(circle $w)" \
  23. favicon-${w}x${w}-error.png
  24. optipng -o6 favicon-${w}x${w}-error.png
  25. echo "Yellow ${w}x${w}"
  26. magick favicon-${w}x${w}.png \
  27. -fill $COLOR_YELLOW \
  28. -draw "$(circle $w)" \
  29. favicon-${w}x${w}-warning.png
  30. optipng -o6 favicon-${w}x${w}-warning.png
  31. echo "Blue ${w}x${w}"
  32. magick favicon-${w}x${w}.png \
  33. -fill $COLOR_BLUE \
  34. -draw "$(circle $w)" \
  35. favicon-${w}x${w}-unread.png
  36. optipng -o6 favicon-${w}x${w}-unread.png
  37. done