Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # name:
  4. # mkicon.sh
  5. #
  6. # Generates icon images from original file
  7. # The original image should be larger than 1024x1024 in pixel
  8. #
  9. # parameters:
  10. # $1:original file
  11. # $2:mac/ios
  12. #
  13. # dependencies:
  14. # sips
  15. #
  16. if [ $# -ne 2 ];then
  17. echo give me an original file and mac/ios
  18. exit 1
  19. fi
  20. org=$1
  21. target=$2
  22. if [ ! -f $org ];then
  23. echo file not found: $org
  24. exit 1
  25. fi
  26. OLD_IFS=$IFS
  27. IFS='.'
  28. set -- $org
  29. prefix=$1
  30. suffix=$2
  31. IFS=$OLD_IFS
  32. case $target in
  33. "mac" ) sizes=(16 32 64 128 256 512 1024);;
  34. "ios" ) sizes=(29 58 87 76 152 60 120 180 \
  35. 40 80 120 72 144 50 100 57 \
  36. 114 512 1024);;
  37. esac
  38. for i in ${sizes[@]}
  39. do
  40. f=${prefix}_${i}.${suffix}
  41. cp $org $f
  42. sips -Z $i $f
  43. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement