export-icons.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. # convert a single svg file into a png in the according drawable dir
  3. svg2png() {
  4. basename=$1
  5. width=$2
  6. height=$3
  7. dest=$4
  8. api=$5
  9. inkscape --export-png=res/$dest$api/$basename.png --export-width=$width --export-height=$height --export-background-opacity=0,0 -C -z asset-graphics/$basename$api.svg
  10. }
  11. # convert a single svg into a group of PNGs for all DPIs
  12. svg2all() {
  13. basename=$1
  14. dpx=$2
  15. dpy=$3
  16. api=$4
  17. while read scale dir ; do
  18. svg2png $basename $(($dpx*$scale)) $(($dpy*$scale)) drawable$dir $api
  19. done <<EOF
  20. 1
  21. 3/2 -hdpi
  22. 2 -xhdpi
  23. 3 -xxhdpi
  24. 4 -xxxhdpi
  25. EOF
  26. }
  27. # convert SVG to launcher icons (sizes at http://stackoverflow.com/a/12768159/539443)
  28. svg2launcher() {
  29. basename=$1
  30. api=$2
  31. svg2all $basename 48 48 $api
  32. svg2png $basename 512 512 ../asset-graphics/
  33. }
  34. # a roster status icon is 66% of a launcher icon, making it 32dp
  35. # action bar icons are 32dp as well
  36. svg2rosteraction() {
  37. basename=$1
  38. svg2all $basename 32 32
  39. }
  40. # a notification bar icon is 16x25dp (pre-v11), or 24dp as of v11
  41. svg2notif() {
  42. sbname=$1
  43. svg2png $sbname 16 25 drawable
  44. svg2png $sbname 24 38 drawable-hdpi
  45. svg2png $sbname 32 50 drawable-xhdpi
  46. svg2all $basename 24 24 -v11
  47. }
  48. svg2chat() {
  49. svg2all $1 18 10
  50. }
  51. # convert chat markers
  52. for file in asset-graphics/ic_chat_*.svg
  53. do
  54. basename=`basename $file .svg`
  55. svg2chat $basename
  56. done
  57. # convert launcher icon
  58. svg2launcher icon
  59. # convert GNU for about dialog
  60. svg2all gnuicon 48 48
  61. # convert statusbar notification icons
  62. svg2notif sb_message
  63. svg2notif ic_online
  64. svg2notif ic_offline
  65. # convert roster status
  66. for file in asset-graphics/ic_action_*.svg asset-graphics/ic_status_*.svg
  67. do
  68. basename=`basename $file .svg`
  69. svg2rosteraction $basename
  70. done