If you have to use GIMP, in my experience the Python scripting is easier than the Scheme. The documentation is awful for either, and you need a lot more effort in order to understand how it works.
In any case, it should be something like this
untested script.
First you'd paste this script into Notepad and fill-in the path to the input directory, as well as the background colour to be removed for transparency.
Then copy the modified script and paste it on the Python console from within GIMP, to execute it.
import os
from gimpfu import *
# FILL THIS IN:
inputDir = "C:\\project\\graphics\\" # Note the double slash.
bgColour = (255, 0, 255)
for file in os.listdir( inputDir )
try:
inputFile = inputDir + file
image = pdb.file_bmp_load( 0, inputFile, inputFile )
pdb.gimp_selection_none( image )
tempLayer = image.layers[0]
pdb.add_layer_alpha( tempLayer ) # Add an alpha channel to the main layer.
pdb.by_color_select( tempLayer, bgColour, 0, 2, 0, 0, 0.0, 0) # Select all the background pixels.
pdb.gimp_edit_clear( tempLayer ) # Clear the background pixels so they're transparent.
outputFile = inputFile.replace( "bmp", "gif" )
pdb.file_gif_save( tempLayer, outputFile, outputFile, 0, 0, 0, 0 )
gimp.delete( image )
except Exception as err:
gimp.message( "Error: " + str( err ) )
Before writing this I went through Google and found these as reference:
-
http://hs.riverdale.k12.or.us/~pnelson/web_design/transparent.html-
http://pastebin.com/jCEKQugN-
http://www.gimp.org/docs/python/