I’m trying to add text to a predefined image, but have failed to do so.
The code I am using is the following:
<?php
header("Content-type: image/png");
if(file_exists("stats_gen.png")){ unlink("stats_gen.png");} //delete old version
$string = "text";
$im = imagecreatefrompng("stats.png");
$textcolor = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 5, 0, 0, $string, $textcolor);
imagepng($im); //show the image for debug purposes
imagepng($im, "stats_gen.png"); //save the image
imagedestroy($im);
?>
stats.png looks like this:
Oh, image format not supported. Well, this: http://lolmewn.nl/stats/stats.png and ends up like http://lolmewn.nl/stats/stats_gen.png which looks crap.
What am I doing wrong? Google doesn’t seem to give any answers…
Make the image background un-transparent. Heh.