MoreBatchScriptGoodness: More scripts!

In the same vein as the script given in BatchImageProcessingHowAndWhy, here’s a handful of simple Imagemagick scripts to make manipulating entire batches of images on Linux quick and simple.

All of the scripts can either be run against a single file, for example: photo-00081.jpg

or run against loads of files automatically in sequence:

 for i in *.jpg; do echo $i; $i; done

Just replace with the name of the script. All of the scripts create new files rather than overwrite the existing ones, so it’s possible to chain the commands one after the other.

For example:

 for i in *.jpg; do echo $i; $i; mono_$i; done

will convert all of the files in the current directory to mono, them lomoize the result. Clever, eh?

As before, copy-and-paste the scripts into a file, then chmod +x to make it executable. Copy it (as root) to /usr/local/bin so they can be run anywhere.

I’ve included a sample image for each script to give you an idea of the results. I reduced the image size down after applying the script so there’s quite a lot of image degredation. Even so, you should get an idea of the end result. Here’s the starting image before the scripts are applied:

This is a simple script which normalizes (auto-levels) the image, then boosts the contrast twice. This is roughly akin to applying an S-curve in Photoshop. It makes the dark parts of the image darker, and the light patches lighter.

 convert -normalize -contrast -contrast $1 enh_$1


This simply converts the image to mono. There’s a thousand-and-one ways to do this, and each has it’s uses. For the sake of simplicity I’ve chosen the easiest to understand; this one just uses the Green channel and makes a monochrome image from that. My digital camera is typical in that it generates the least noise in the Greens and most in the Reds, so this script creates a strong, noise-free image.

 convert -separate -channel Green $1 mono_$1


Using this script, the redness of the rose has turned almost black. That’s thanks to the use of the Green channel. I was going to amend the script to suit this example, but I like it as it is! :)

 convert -sepia-tone 80% $1 sepia_$1

This is a common (and probably over-used) effect to give a old-worlde style to your shots. It works for some pics, but it’s probably overkill on a whole batch of shots.


It’s well worth reading through the examples given at the Imagemagick site for more ideas. If you make scripts of your own, share them!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.