MoreBatchScriptGoodness: More scripts!

In the same vein as the lomo.sh 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:

 mono.sh photo-00081.jpg

or run against loads of files automatically in sequence:

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

Just replace mono.sh 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; mono.sh $i; lomo.sh 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 filename.sh 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:

http://home.greywulf.net/images/sample_images/sample.jpg

enhance.sh

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.

 #!/bin/bash
 convert -normalize -contrast -contrast $1 enh_$1

Result:
http://home.greywulf.net/images/sample_images/enh_sample.jpg

mono.sh

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.

 #!/bin/bash
 convert -separate -channel Green $1 mono_$1

Result:
http://home.greywulf.net/images/sample_images/mono_sample.jpg

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! :)

sepia.sh

 #!/bin/bash
 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.

Result:
http://home.greywulf.net/images/sample_images/sepia_sample.jpg

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!

You may also like...

Leave a Reply