I have a PNG image, which is partly transparent. What I need is to make one more color on the image transparent too. I searched on the internet and here as well and I found some tutorials, but the problem is, that when I try it, it does indeed make my desired color transparent, but it does not "add it" to the original transparent alpha channel, but instead creates a new alpha, so I end up with an image, where my desired color is transparent, but the original parts that were transparent too are now a solid black background.
So far I came up with the following code, which does what I described above:
<?php
header('Content-Type: image/png');
$file="image.png";
$im = imagecreatefrompng($file);
$new = imagecolorclosest($im, 255, 0, 255);
imagecolortransparent($im, $new);
imagepng($im);
imagedestroy($im);
?>
Any ideas how to do what I need? Thanks in advance.