home

Love life, love sports, love to learn, & love...

Blog

Thought,  done  &  record.

订阅到QQ邮箱 google reader google reader

Image Magick bash script to resize and crop images

#!/bin/sh

# script to resize and crop

dir="/Users/data/files/candidate/photo/"
resume=resume
orig=_orig
cd "$dir$orig"
for k in `ls *.jpg`
do
h=`identify -format "%h" $k`
w=`identify -format "%w" $k`
#echo "$k, w:$w, h:$h"

if [ $w -ge $h ]
    then
     convert $k -resize x72 -crop 72x72+0+0  "$dir$resume/$k"

    else
     convert $k -resize 72x -crop 72x72+0+0 "$dir$resume/$k"
     #echo "portrait"
fi

done
回顶部