PHP PNG透明度

I have a code which is converting PNG to PNG (the PNG is originally bad! There is no transparency) so my task is to restore the transpareny.

$image = imageCreateFromPng("./kep.png");
$background = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $background);
imagealphablending($image, false);
imagesavealpha($image, true);
header('Content-type: image/png');
imagepng($image,NULL);

This is my code but not working. I receive a black backgrounded picture. I have googled hours but nothing helped.

The original PNG has BLACK color when i open it with Photoshop. I want to make a code which make a good transparent png from the bad png.

(If i open the bad png with gimp, then save as png the transparency is good, but i need something automatically.)

What i missed? Thanks!