半分の大きさの画像を作るソース

to_half (){
  for file in *
    do
      echo $file
      width=`sips --getProperty pixelWidth $file | sed -E "s/.*pixelWidth: ([0-9]+)/\1/g" | tail -1`
      width=`expr $width / 2`
      newFile=`echo $file | sed 's/@2x//'`

      srcAbspath=$(cd $(dirname "$file") && pwd)/$(basename "$file")
      distAbspath=$(cd $(dirname "$newFile") && pwd)/$(basename "$newFile")
      sips -s format png --resampleWidth $width $srcAbspath --out $distAbspath
    done
}