I'm not aware of any ready-made functions. But I suppose you could go trough every pixel of the image and change it's colour...
I haven't tried it myself but you can look at the function imagecolorset() in the GD library It does a color fill like effect, that could help with the white background.
You could try the imagefilter function http://lv.php.net/imagefilter - but that will not give your direct access to replace one color with another, just changing the r/g/b components.
A very low level solution could be implemented using imagesetpixel http://nl2.php.net/imagesetpixel to set the new pixel values.
I had trouble making this solution work. The image cannot be a true color image. Convert it first with imagetruecolortopalette();
$imgname = "test.gif"; $im = imagecreatefromgif ($imgname);
imagetruecolortopalette($im,false, 255);
$index = imagecolorclosest ( $im, 255,255,255 ); // get White COlor imagecolorset($im,$index,92,92,92); // SET NEW COLOR
$imgname = "result.gif"; imagegif($im, $imgname ); // save image as gif imagedestroy($im);
@David Crowell - What if we want to change a set color on a true color image.... is there some way of doing that?
As I need to be able to do this for HTML5 video player controls