Wednesday, August 23, 2006

Expedient image processing

When I use Windows, I make it a point to have IrfanView handle most of my image-related processing, such as conversion and viewing.

Now that I've made the switch, I naturally looked for the same functionality with gThumb and GQView. Sadly, all they offered was image-viewing. GIMP, on the other hand, only allowed processing one image at a time. I needed a way to resize about 200+ pictures as a batch.

The UbuntuForums led me to ImageMagick.

ImagMagick is a suite of image-processing tools that make use of the command-line interface (CLI). Yes, it *is* possible to handle images with that blinking cursor on a black background. Apparently, Ubuntu already has the ImageMagick tools installed, so all I had to do was figure out how to make things work.

I then found two simple tutorials on the subject:
  1. Graphics from the command line
  2. More graphics from the command line
A few minutes of study, and I was already resizing JPGs in the background. What I did notice was that the CPU took a hit when ImageMagick was running. Fully 100% of the CPU was used (maybe also because I also had thunar to show thumbnails, firefox with 4 tabs, gaim, etc.)

ImageMagick allowed me to experience some of the intricacies of the Linux OS, specifically with scripting. Check out the simple script I copied then modified:
for $img in 'ls *.JPG'
convert -resize 1024x $img new-$img.JPG
Its limitations:
  1. The filename extension is case-sensitive and only jpeg files will be processed.
  2. Resizing is limited to images with a landscape orientation.
  3. It also assumes that the size of the output is 1024 pixels on the horizontal side.
This script will be undergoing more modifications as I learn more about ImageMagick. In the meantime, my needs have been fulfilled.

No comments: