Guest User

Untitled

a guest
Aug 14th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. : '
  4. Requirements:
  5. $ brew install imagemagick
  6.  
  7. Usage:
  8. $ ./icon-tool iconPath destination
  9.  
  10. Where:
  11. * iconpath: the path of the icon you will use as source, it has be 1024 x 1024. Defaults to: ../skin/res/ios/icon.png
  12. * destination: the folder where you want to output the icon. Defaults to: ../skin/res/ios/icons
  13.  
  14. - Android ouput:
  15. Not available yet, it will be generated by Android studio for now.
  16.  
  17. - iOS output:
  18. <icon src="res/ios/icons/Icon-App-20x20@1x.png" width="20" height="20" />
  19. <icon src="res/ios/icons/Icon-App-20x20@2x.png" width="40" height="40" />
  20. <icon src="res/ios/icons/Icon-App-20x20@3x.png" width="60" height="60" />
  21. <icon src="res/ios/icons/Icon-App-29x29@1x.png" width="29" height="29" />
  22. <icon src="res/ios/icons/Icon-App-29x29@2x.png" width="58" height="58" />
  23. <icon src="res/ios/icons/Icon-App-29x29@3x.png" width="87" height="87" />
  24. <icon src="res/ios/icons/Icon-App-40x40@1x.png" width="40" height="40" />
  25. <icon src="res/ios/icons/Icon-App-40x40@2x.png" width="80" height="80" />
  26. <icon src="res/ios/icons/Icon-App-40x40@3x.png" width="120" height="120" />
  27. <icon src="res/ios/icons/Icon-App-57x57@1x.png" width="57" height="57" />
  28. <icon src="res/ios/icons/Icon-App-57x57@2x.png" width="114" height="114" />
  29. <icon src="res/ios/icons/Icon-App-60x60@1x.png" width="60" height="60" />
  30. <icon src="res/ios/icons/Icon-App-60x60@2x.png" width="120" height="120" />
  31. <icon src="res/ios/icons/Icon-App-60x60@3x.png" width="180" height="180" />
  32. <icon src="res/ios/icons/Icon-App-72x72@1x.png" width="72" height="72" />
  33. <icon src="res/ios/icons/Icon-App-72x72@2x.png" width="144" height="144" />
  34. <icon src="res/ios/icons/Icon-App-76x76@1x.png" width="76" height="76" />
  35. <icon src="res/ios/icons/Icon-App-76x76@2x.png" width="152" height="152" />
  36. <icon src="res/ios/icons/Icon-App-76x76@3x.png" width="228" height="228" />
  37. <icon src="res/ios/icons/Icon-App-83.5x83.5@2x.png" width="167" height="167" />
  38. <icon src="res/ios/icons/Icon-App-50x50@1x.png" width="50" height="50" />
  39. <icon src="res/ios/icons/Icon-App-50x50@2x.png" width="100" height="100" />
  40. <icon src="res/ios/icons/Icon-App-24x24@2x.png" width="48" height="48" />
  41. <icon src="res/ios/icons/Icon-App-27.5x27.5@2x.png" width="55" height="55" />
  42. <icon src="res/ios/icons/Icon-App-44x44@2x.png" width="88" height="88" />
  43. <icon src="res/ios/icons/Icon-App-86x86@2x.png" width="172" height="172" />
  44. <icon src="res/ios/icons/Icon-App-98x98@2x.png" width="196" height="196" />
  45. <icon src="res/ios/icons/Icon-App-1024x1024@1x.png" width="1024" height="1024" />
  46. '
  47.  
  48. sizes="20x1 20x2 20x3 24x2 27.5x2 29x1 29x2 29x3 40x1 40x2 40x3 44x2 50x1 50x2 57x1 57x2 60x1 60x2 60x3 72x1 72x2 76x1 76x2 76x3 83.5x2 86x2 98x2 1024x1"
  49.  
  50. source=${1:-"../skin/res/ios/icon.png"}
  51. dst=${2:-"../skin/res/ios/icons"}
  52.  
  53. for s in $sizes;do
  54. size=${s%x*}
  55. scale=${s##*x}
  56. resize=$(bc <<< ${size}*${scale} )
  57. generatedIcon=$dst/"Icon-App-${size}x${size}@${scale}x.png"
  58. convert "$source" -resize ${resize}x${resize} $generatedIcon
  59. if [ -f $generatedIcon ];
  60. then
  61. echo "Created: $generatedIcon"
  62. else
  63. echo "Could not create $generatedIcon"
  64. fi
  65. done
Add Comment
Please, Sign In to add comment