Does anyone know how i can remove the color from an image on the fly. I have a huge collection of jpeg images that are going to be used for an ecommerce site. The problem is the images all have an extremely ugly background color. I was wondering if anyone knew how to remove this color with the gd library or if it can't be removed, as they are jpegs and wont' support transparency, can the color be coverted to white? There are over 10,000 images and i dont' want to have to go through all of them one by one.
Here is a sample picture:
All of the images have this same unique background color......
You just have to get the width and height of the image, and then loop through each pixel, using imagecolorat() to get the color at the specified pixel. Then check to see if this pixel is the color that you want to change and if so use imagesetpixel() to change the color.
thanks for the reply. is there anyway you could supply me with a sample chunk of code as i am very new to gd library. If not its ok im sure i can figure it out.
Keep in mind that this will only convert the EXACT colour listed. The sample picture you showed has anti-aliasing between the image proper, and the background colour. Removing that single shade of turqoise will leave the darker shades that show up around the subject.
Are you familiar with Photoshop? You can set up a batch action that could go through your image directory, open each image, convert the background colour (and use anti-aliasing so it will likely get more shades of turqoise), and re-save it.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I've got quite a bit of Fireworks experience but have to say I've never particulary tried to look for a batch function, as the only occasional time I need it it is covered by a freeware photoediting app. However, that said, I a) haven't seen one and b) don't believe there is one as it is mainly for the creation of images for the web rather than photoediting. Or maybe I'm very wrong and have just put my foot in it.