Re: 请教如何批处理图片
On Sat, Jul 14, 2007 at 07:29:55PM +0800, renws wrote:
> 如果我有一组照片,想改成同样的尺寸,比如500x375 px ,怎样进行批处理?
> 我以前都是用GIMP一张一张地改,不过也太没效率了。
>
> 在Google上搜了半天,没有找到对我有实质性帮助的内容(很有可能是我看不
> 懂)。
> 还望各位帮忙。
> --
进入要转换相片大小的目录,执行附件中的脚本(一定要有执行权哦):
cd /path/to/photos
/path/to/imgconv *.*
Enjoy ;)
--
Alex Yan
阎啸天
2007-07-15
#!/bin/bash
# Purpose: imgconv
# Author: Yan Xiaotian(yanxiaotian@bupt-bcnl.com)
# Date: 2007/07/15
#default options
dir=./`basename ${PWD}-500x375`
convertor=`which convert`
name=`basename $0`
#help version ignored here...
if [ -z $convertor ]; then
echo "convert not found... Please install ImageMagick."
exit 1
fi
mkdir -p $dir
echo "Converting photos to $dir"
files=$(echo $@ | sed 's/ /\n/g' | sort)
for imagefile in $files; do
echo -n "converting $imagefile ."
$convertor -resize 500x375 $imagefile $dir/$imagefile
echo "..done"
done
Reply to: