Batch Resize Image Script

May 11, 2005

This simple script will go through all *.JPG files in the current directory and re-size them to 640x480.

#!/bin/sh
 
for file in *.JPG
do 
	echo "Resizing file $file ..."
	convert -resize 640x480 "$file" "$file"
done

If you don't have convert installed, install it with:

sudo apt-get install imagemagick

Related Posts

5 Comments

Comment August 5, 2005 by anonymous
Great. Nice and easy. Thanks. I added quotes to fix spaces in filenames: convert -resize 640x480 "$file" "$file"
Comment January 16, 2007 by RJ
Never knew convert command existed. I have LOTS of images to be reduced in size. Thanks cause you lead me to the convert.
Comment August 14, 2007 by rince
Hi, thanks for this script... Is it possible to just convert one file in het current directory, instead of *.JPG? I'm kinda new at this... i would like to use it as convert script for xfce's Thunar (custom actions) thx
Comment September 21, 2007 by luziy
whoaaa command not found
Comment June 1, 2008 by anonymous
well, it only works if convert is installed on your system...