Automatic Photo Resizing Script for Linux
by Chad Hauris, Retro Electronics and Audio Lab, Midland, TX. 1/17/07

One of the nice things about Linux is that, unlike Windows, there is a command-line based program to do almost any task, including those dealing with photos and audio.
Using this photo re-sizing script has made it a lot easier to prepare the small versions of the photos that are used on the site.

This uses a command from ImageMagick called "convert".

Here is the script:

#!/bin/bash

for i in *.jpg
do

    nice -n 15 convert -resize 15% -quality 55 $i  small_"$i"

    echo

    echo "File" $i " converted"

done

Once you have put the text into an editor you can make the file executable by issuing the su command and then chmod filename a+x.
These settings convert the original jpg file to 15% of the original size, set the resulting file to a quality level of 55, and name the new file small_oldfile.jpg
Just copy the script file into the directory where the jpg files are to use it.

I am still a beginner with linux scripting so I'm sure the experts could do something more elegant but this has worked so well as a labor-saving tool for me when working with photos.


Special Features Page

Retro Electronics Home Page