I believe GD has an issue with transparent mattes and alpha blending. It seems GD thinks that some images have a black matte transparency (meaning that the image is built on a black matte instead of transparent).
And while "alan hogan dot com slash contact" solution does deal with this, the results seem to be... glitchy. you get different results each time you do it, and they are not always the best.
So I made a different solution that, while it looks better on a white background and is consistent, still sort of mangles the image just a bit by merging all blended pixels with the transparent color.
// Load image
$img = imagecreatefrompng('my_broken_png.png');
// Make matte canvas
$matte = imagecreatetruecolor(16,16);
$trans_color = imagecolorallocatealpha($matte,254,254,254,0);
imagefill($matte, 0,0,$trans_color);
// Put the old image on the matte
imagecopy($matte,$img,0,0,0,0,16,16);
// Turn the matte color into full alpha (blended pixels will not be affected)
imagecolortransparent($matte,$trans_color);
// Display image
header('Content-Type: image/gif');
imagegif($matte);