The Power of ImageMagick

ImageMagick is a software package that comes with standard with Red Hat Linux. It is an amazingly powerful piece of software, and although it's not super intuitive, it's worth your time to learn how to use it. Besides, it's pretty easy to start using it to do some useful things.

Let's say you want to get basic info about a directory of images. Just cd to the directory and run identify *. You'll get a list of file dimensions, file formats, and other info for each file.

What if you want to convert a directory full of images from, say, PNG to JPG? In your favorite text editor, type the following:

for i in *
do
 convert $i $i.$2
 rename .$1.$2 .$2 *.$1.$2
done

This creates a for loop that looks at every file in a directory and converts it from file type 1 to file type 2.

After entering the above in your text editor, save the file as "convertimage" in the bin directory found in your home directory (what? you don't have a bin directory in your home directory? Make one!). On my machine, convertimage is in /home/rsgranne/bin.

Now cd to your bin directory and enter the following:

chmod 774 convertimage

You just made convertimage into an executable command. Now cd to the directory with the images you'd like to convert. Let's say they're all PNGs and you want to convert them to GIFs. Just type the following (remember that Linux is case-sensitive):

convertimage png gif

Now type ls to check what you've done. You've still got all your original images with the png extension, but you've also got new images with the gif extension.

These are just two of the cool things that ImageMagick can do for you. This wonderful program also makes it easy for you to automate things like image resizing and on-the-fly image creation. For more info, check out the ImageMagick Web site at http://www.imagemagick.org.

WebSanity Top Secret