Skip to content

Instantly share code, notes, and snippets.

@jungbin-kim
Last active June 14, 2017 09:56
Show Gist options
  • Save jungbin-kim/244409892e6d993b16bbb1e143fe2f58 to your computer and use it in GitHub Desktop.
Save jungbin-kim/244409892e6d993b16bbb1e143fe2f58 to your computer and use it in GitHub Desktop.
macOS command인 sips를 사용하여 세로로 여러 이미지들이 합쳐진 하나의 이미지를 분리해보려고 하였다. 하지만, 실패함. sips는 crop을 시작하고자 하는 width와 height를 지정할 수 없기 때문임.
#!/bin/sh
[ -z "$1" ] && echo "Usage: $ ./crop360Image {image path} " && exit 1
ImagePath="$1"
ImageWidth=$(sips -g pixelWidth $ImagePath | tail -n1 | cut -d" " -f4)
ImageHeight=$(sips -g pixelHeight $ImagePath | tail -n1 | cut -d" " -f4)
echo $ImageWidth
echo $ImageHeight
OutputPath="./crop360"
if [ ! -d $OutputPath ]
then
mkdir $OutputPath
fi
CropNum=24
CropHeight=`expr $ImageHeight / $CropNum`
for ((i=1; i<=$CropNum; i++))
do
echo $i
h=`expr $CropHeight \* $i`
sips -c $h $ImageWidth $ImagePath --out $OutputPath/$i.jpg
done
echo "clean"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment