HowTo – Batch Image Resize on Linux

November 16, 2007

Suppose you want resize every your photos to put it on web. As you know, you can’t upload your photos on a webpage with the highest resolution because a web gallery became inaccesible and too slow to load. Suppose that you have a folder containing every photos of you holidays and you want resize it at 640 of width mantaining original aspect ratio. To make a resize there are many tools but I suggest a command line tool called “mogrify”. This tool will be installed with ImageMagick Libraries, so you have to install ImageMagick on you Linux.

I assuming that you have installed Ubuntu Gutsy:

sudo apt-get install imagemagick

After ImageMagick installation, you can use mogrify. For example, I have a folder called “holidays” locate in “/home/user/photos/“. I have to change my path, make a thumbs folder and copy original images on “thumbs folder”. After that I can start image resizing process:

cd /home/user/photos/holidays
mkdir thumbs
cp /home/user/photos/holidays/* /home/user/photos/holidays/thumbs/
cd thumbs

mogrify -resize 640 *.jpg

Now I can see on “/home/user/photos/holidays/thumbs/” every my image file resized to 640 of width. If you want force resizing to a particulare size without mantaining original aspect ratio you could change mogrify options:

mogrify -resize 640×480! *.jpg

Good Job Man! I hope this howto will be useful for you.

Related Post