Batch converting images using ImageMagick

Bismillaahir Rahmaanir Raheem

The command you want is mogrify.

I am working with some images generated from within Windows XP, and they (sometimes thousands) are all in uncompressed bitmap files.  I wanted to find a free-and-open-source application to do the batch conversion easily, and I came across ImageMagick, which I had known about for a while.  In short, ImageMagick is a library and set of utilites for manupulating and converting images formats.

The most common utility is convert.  However, it is designed to work on one file per invocation.  So, without having to learn a little DOS-style scripting, convert comes-up short.  However, mogrify can work on more than one file at a time, alhamdulillaah.

So, for example, if you would like to convert a directory full of TGA images, the command would be:

mogrify -format png *.tga

And, if said TGA images happen to use the alpha channel inappropriately (as they did in my case), then simply disable it with this modified command:

mogrify -format png -alpha off *.tga

So there you have it! Happy converting!

Leave a Reply

Your email address will not be published. Required fields are marked *