Automate image editing with GIMP

I needed to remove the white background from several hundred images in PNG format and replace it with transparency

For a project I was recently working on I needed to remove the white background from several hundred images in PNG format and replace it with transparency. I know you can automate Photoshop but that's like getting into a Sherman tank to go shopping at your local supermarket. Another constraint (other than my reluctance to wrangle Photoshop) was the need to be able to do this in the future as part of a process to be built into a virtual machine running Linux.

Then I remembered GIMP, the GNU Image Manipulation Program. GIMP, a free, open source image editor, that's available for Windows, OS X, Ubuntu, Debian, openSUSE, Fedora, Mandriva, BSD, and Solaris and one of its neat features is an automation plugin  called BIMP (though you can also automate GIMP with Python which, like GIMP's batch mode, is not for beginners).

Installing GIMP is fast and painless so I won't belabor it here. Once installed you need to download BIMP, the Batch Image Manipulation Plugin, and install it (see Wikibooks GIMP/Installing Plugins for the details). Again, easy-peasey.

When GIMP is restarted you'll find BIMP hidden in the file menu.

To remove the white backgrounds I first had to reformat the PNG files to RGB from their default  indexed colour mode. This is something you'll usually want to do otherwise the image will be constrained to the palette used in the file. The command I needed is in the "Other GIMP procedure" picker list as gimp-image-convert-rgb.

Once you've select that and clicked OK you return to the "Other GIMP procedure" picker and select plug-in-colortoalpha. Then click on the color button and select your target color (in my case it was white). You've now built a sequence of simple manipulations that can be run on one or more files.

Now all you need to do is add  images with the "Add image" file button, select your output folder, and click "Apply". Voila!

So, if you don't want to shell out the big bucks for the likes of Photoshop you can't beat GIMP's price and there are a huge number of training guides on the GIMP site and elsewhere online.

While GIMP is by no means a simple program (it's really just as complex as Photoshop and some might argue more so) there are many functions and operations that are easier. If you've got any good GIMP tips, let me know ...

Join the TechWorld newsletter!

Error: Please check your email address.

Tags mandrivaopen sourceeditingsusefedorasoftwareGraphics &ampubuntu

More about DebianFedoraLinuxMandrivaUbuntu

Show Comments

Market Place