Patriot Posted June 11, 2009 Share Posted June 11, 2009 Thanks for helping. I'm having trouble with the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php $image = imagecreatefrompng("images/esuom.png"); if(!$image) die("Error loading image."); $text_color = imagecolorallocate($image, 13, 37, 62); $x = 100; $y = 30; $fontsize = 12; $fontfile = "fonts/VAG Rounded BT.ttf"; $text = "Hello World!"; imagettftext($image, $fontsize, 0, $x, $y, $text_color, $fontfile, $text); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> </body> </html> I have it uploaded here: http://imobworld.com/dynamicsigs/ Does anyone know what's wrong? Thanks, Gil Quote Link to comment https://forums.phpfreaks.com/topic/161843-solved-trouble-writing-text-to-an-image/ Share on other sites More sharing options...
RussellReal Posted June 11, 2009 Share Posted June 11, 2009 first ofall, when you start sending text, you send the headers, so right off the bat, your script isn't going to work with all that html surrounding your php code so first step up is a big one.. get rid of the html.. <?php $image = imagecreatefrompng("images/esuom.png"); if(!$image) die("Error loading image."); $text_color = imagecolorallocate($image, 13, 37, 62); $x = 100; $y = 30; $fontsize = 12; $fontfile = "fonts/VAG Rounded BT.ttf"; $text = "Hello World!"; imagettftext($image, $fontsize, 0, $x, $y, $text_color, $fontfile, $text); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> oh.. and nice font name VAG Rounded Quote Link to comment https://forums.phpfreaks.com/topic/161843-solved-trouble-writing-text-to-an-image/#findComment-853882 Share on other sites More sharing options...
Patriot Posted June 11, 2009 Author Share Posted June 11, 2009 Haha that did the trick! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/161843-solved-trouble-writing-text-to-an-image/#findComment-853884 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.