Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. function halfPNGs(){
  2. dir=$1
  3. n=0
  4. while read f
  5. do
  6. # Image name
  7. i=$(basename "$f")
  8. echo $i
  9. if [[ $i == *\@2x\.png ]]; then
  10. # Height of image
  11. h=$(sips -g pixelHeight $f)
  12. # Cut off all but the numbers
  13. h=${h#*: }
  14. # Width of image
  15. w=$(sips -g pixelWidth $f)
  16. # Cut off all but the numbers
  17. w=${w#*: }
  18. # Resize the png and output in the same folder with @2x cut off
  19. sips -s format png -z $(expr $h / 2) $(expr $w / 2) $f --out ${f%@*}\.png
  20. fi
  21. done < <(find $dir -iname '*@2x.png') # Find all pngs in directory
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement