$img = imagecreatefrompng($your_image);
//или
//$img = imagecreatefromstring($your_image);
//или
//$img = imagecreatefromjpeg($your_image);
$white = imagecolorallocate($img, 255, 255, 255);
imagecolortransparent($img, $white);
imagepng($img, $output_file_name);