顯示具有 批次轉換圖檔 標籤的文章。 顯示所有文章
顯示具有 批次轉換圖檔 標籤的文章。 顯示所有文章

2009年5月24日 星期日

在 Linux 下批次轉換圖片尺寸的方法(該目錄下都是圖檔)

利用Synaptic安裝好ImageMagick後(尋找imagemagick),其中有convert可以來進行圖片轉檔工作 (位於/usr/bin目錄之下),語法如下:

#convert [options ...] file [ [options ...] file ...] [options ...] file

其中參數-resize 就可以改變圖片大小

可以使用百分比,如:

convert -resize 30%x30%

img-resize.sh

內容如下(個人常用的縮放比為30%x30%):
filelist=$(ls $dir)
for filename in $filelist
do
convert -resize 30%x30% $filename resize_$filename
done