Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 1000 jpg files in which all have a white background. Is is possible to change the white background color to red (for example) of all the files in order not to have to do it one by one ?

I would prefer to use Linux but I can handle Windows.

For example, change the below logo with a white background to have a red background.

enter image description here

share|improve this question
Your question is incomplete. How do the files look like? Can you maybe show us an example? What do you want to do? Do you just want to replace #FFFFFF white with another color? What do you mean by "modify"? Please edit the question to include some more details, otherwise we won't be able to help you. – slhck Jul 10 '11 at 20:54
Edited tags - two OS tags aren't generally very informative on their own. – new123456 Jul 10 '11 at 22:04

If there is a way to do, then convert is your friend.

I have used convert for many things, but not specifically for this. Also, whther you actually have a background color in your images is a question -- it may just be a part of the image which has the same color as the background (which is subtle different) -- however even in that case convert may be able to help.

Looking at man convert there is an option for changing background color. There is also a option opaque to change a particular color into the background color.

So playing around with your particular images, and the options you may find what works for your images.

Then the final step would be to write a small shell script to loop though all your images, like this

mkdir converted_img
for img in $(ls orig_image/*) ; do
   convert {insert-options-which-does-the-job} orig_image/$img converted_img/$img

and you should be all done

share|improve this answer
There is a -background option to convert, just to let you know. – new123456 Jul 11 '11 at 0:27
Just to add to the answer, if you don't have the "convert" tool, you must install the ImageMagick set of applications. – jmbouffard Jul 11 '11 at 2:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .