Sep 10, 2012 – 工具 & 软件 – 编程语言  脚本  批处理   – Bai

Image Magick bash script to resize and crop images

 1     #!/bin/sh
 2     
 3     # script to resize and crop
 4     
 5     dir="/Users/data/files/candidate/photo/"
 6     resume=resume
 7     orig=_orig
 8     cd "$dir$orig"
 9     for k in `ls *.jpg`
10     do
11  h=`identify -format "%h" $k`
12  w=`identify -format "%w" $k`
13  #echo "$k, w:$w, h:$h"
14  
15  if [ $w -ge $h ]
16      then
17       convert $k -resize x72 -crop 72x72+0+0  "$dir$resume/$k"
18       
19      else
20       convert $k -resize 72x -crop 72x72+0+0 "$dir$resume/$k"
21       #echo "portrait"
22  fi
23 
24     done

上一篇:

下一篇:

回顶部