You should be able to work with the palette instead of going through every pixel in that case:
<?PHP
$myRed = 255;
$myGreen = 0;
$myBlue = 0;
$im = imagecreatefrompng('http://s25.postimg.org/ll0dzblan/image.png');
imageAlphaBlending($im, true);
imageSaveAlpha($im, true);
if (imageistruecolor($im))
{
$sx = imagesx($im);
$sy = imagesy($im);
for ($x = 0; $x < $sx; $x++)
{
for ($y = 0; $y < $sy; $y++)
{
$c = imagecolorat($im, $x, $y);
$a = $c & 0xFF000000;
$newColor = $a | $myRed << 16 | $myGreen << 8 | $myBlue;
imagesetpixel($im, $x, $y, $newColor );
}
}
} else {
$numColors = imagecolorstotal($im);
$transparent = imagecolortransparent($im);
for ($i=0; $i < $numColors; $i++)
{
if ($i != $transparent)
imagecolorset($im, $i, $myRed, $myGreen, $myBlue, $myAlpha);
}
}
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>