find . -maxdepth 1 -name "*[jpg,png]" -type f | while read img ; do
new_img=$(basename $img)
ext=${new_img##*.} # 扩展名
d="./small" # 获取目录名
new_img=$d/${new_img} # 保存的名字为 ./small/xxx.jpg
echo "Start converting $img ..."
/usr/local/GraphicsMagick/bin/gm convert $img -thumbnail 238x138!
-strip +profile '*' -quality 90 -extent 238x138 $new_img
echo "Done." ;
done
转载于:https://my.oschina.net/chinaearl/blog/272305