build-png.sh 1.2 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # The default flags are picked up from country-flag-icons by Wil Linssen:
  3. # https://github.com/linssen/country-flag-icons
  4. path_to_svg=../country-flag-icons/images/svg
  5. svgs=""
  6. for alpha2 in sa by bg cz dk de gr gb es ee fi fr ie in hr hu id is it \
  7. il jp kr lt lv mk my mt nl no pl pt ro ru sk si al rs se \
  8. th tr ua vn cn ; do
  9. # Convert an alpha-2 code to an alpha-3 code according to ISO 3166-1
  10. alpha3=$(grep "^$alpha2" map|cut -f2)
  11. svgs="$svgs $path_to_svg/$alpha3.svg"
  12. done
  13. # United nation flag is not supported by the country-flag-icons project,
  14. # so download a copy directly from wikipedia
  15. wget -qOun.svg https://upload.wikimedia.org/wikipedia/commons/2/2f/Flag_of_the_United_Nations.svg
  16. svgs="$svgs un.svg"
  17. montage $svgs -tile 1x -resize 14x11\! -geometry '14x11>+0+0' -gravity NorthWest small.png
  18. montage $svgs -tile 1x -resize 22x16\! -geometry '22x16>+0+0' -gravity NorthWest medium.png
  19. montage $svgs -tile 1x -resize 30x22\! -geometry '30x22>+0+0' -gravity NorthWest large.png
  20. montage small.png medium.png large.png -mode Concatenate -background transparent -tile 1x4 sprite.png
  21. pngcrush sprite.png languages.png
  22. rm un.svg small.png medium.png large.png sprite.png