[SOLVED] Putting dynamic text on a static image
Posted: Sat Jun 26, 2004 2:14 pm
Hello.
I have a static image with a place on which dynamic text may be placed. I made code to dothis, but I have a problem with this. I want black text on a white background, but I get yellow on white instead, and it looks bad. Here's the code, please help me.
I have a static image with a place on which dynamic text may be placed. I made code to dothis, but I have a problem with this. I want black text on a white background, but I get yellow on white instead, and it looks bad. Here's the code, please help me.
Code: Select all
$origpng= "testpic.png";
$imgsize = getimagesize($origpng);
$newwidth = round($imgsize['0']/1);
$newheight = round($imgsize['1']/1);
$imgwidth = $imgsize['0'];
$imgheight = $imgsize['1'];
$image = imagecreatefrompng($origpng);
$newimage = imagecreate($newwidth, $newheight);
//i imagine the problem is here
$bg = imagecolorallocate($image, 0,0,0);
$black = imagecolorallocate($image, 0, 0, 255); //I also tried 0,0,0 and 255, 255, 255 to no avail
imagecopyresized($newimage, $image, 0, 0, 0, 0, $newwidth, $newheight, $imgwidth, $imgheight);
imagedestroy($image);
imagestring($newimage, 2, 20, 20, "some text here", $black);
header("Content-type: image/png");
imagepng($newimage);
imagedestroy($newimage);
?>