Linux命令

mac下批量旋转翻转90度图片

是个小众需求,我们希望把下载下来的图片进行90度翻转
例如脚本名称 turn.sh

#!/bin/zsh
find $1 -name \*.jpeg > alljpg.lst
for i in `cat alljpg.lst`
do
width=`rdjpgcom -v $i|grep "JPEG image is" |awk -F " " '{ print $4 }'|sed 's/w//g'`
heigh=`rdjpgcom -v $i|grep "JPEG image is" |awk -F " " '{ print $6 }'|sed 's/h,//g'`
echo "pic filename is:"$i" and width is: "$width" and the heigh is: "$heigh
  if [ ${width} -lt ${heigh} ]; then
        echo "change -90 pic ..."
        sips -r -90 $i
        echo "sips -90 done"
  fi
done
exit;

假如你有个文件夹picture,里面都是jpeg文件,就可以执行脚本:
./turn.sh picture

脚本里是逆时针翻转,如果顺时针就是+90