Batch images conversion – color to transparency from the linux terminal

I’ve been re-theming and old forum and the themes that are available are a little less than perfect for our needs. I found a few suitable templates but it still results in me creating a mash-up. Some of the images (though gif) set the image background color to that of the site background. As I was using a different color, this obviously looked bad but I wasn’t about to manually edit all the files to give them transparency.

Being aware of the amazing command line tool for Linux, ImageMagick, I set out to find a tool to help me. I found a transparency flag, calculated the RGB values with the eyedropper in GIMP, then after a test run, I through it in a for loop.

screenshot2

So a directory down from my image source, I created a folder called “new” and ran the following color and like magic, they were all converted.

for image in *.gif; do convert -transparent 'RGB(48,71,94)' $image ../new/$image; done
Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • BlogMemes
  • Furl
  • NewsVine
  • Reddit
  • SphereIt
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Leave a comment

Please be polite and on topic. Your e-mail will never be published.