Dragosvr92 Posted August 28, 2010 Share Posted August 28, 2010 Hello i just learned how to use .ttf fonts on a webpage ,but i noticed that IE Browsers arent supporting it so i thought to make add the Fonted Text into a image so IE Browsers will see the font in a image and not a replaced font text Could someone please provide me a Simple Script to make a PNG image with the text and font and a invisible background ? Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/ Share on other sites More sharing options...
jcbones Posted August 28, 2010 Share Posted August 28, 2010 http://www.thesitewizard.com/php/create-image.shtml Let us know if you get stuck. Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104578 Share on other sites More sharing options...
litebearer Posted August 28, 2010 Share Posted August 28, 2010 As an aside... If you want to use fonts in the webpage w/o resorting to graphics, take a look here... http://www.cre8ivecommando.com/the-best-way-to-embed-a-font-in-your-website-2025/ I use it here http://the-gypsy-king.com/ Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104584 Share on other sites More sharing options...
Dragosvr92 Posted August 28, 2010 Author Share Posted August 28, 2010 thanks litebearer but i know how to use that.. i only want a way to output the text output with the font into a png image Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104595 Share on other sites More sharing options...
Dragosvr92 Posted August 28, 2010 Author Share Posted August 28, 2010 Can anyone help me on this please Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104683 Share on other sites More sharing options...
litebearer Posted August 28, 2010 Share Posted August 28, 2010 http://visionmasterdesigns.com/tutorial-convert-text-into-transparent-png-image-using-php/ Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104705 Share on other sites More sharing options...
Dragosvr92 Posted August 29, 2010 Author Share Posted August 29, 2010 it says the image contains errors as most scripts i used did..... Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104715 Share on other sites More sharing options...
PaulRyan Posted August 29, 2010 Share Posted August 29, 2010 I beleive this is what your looking for TheKiller... http://php.net/manual/en/function.imagettftext.php If I have some time, I'll make a mock-up script for you to look at Thanks, Paul. Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104722 Share on other sites More sharing options...
Dragosvr92 Posted August 29, 2010 Author Share Posted August 29, 2010 Thanks Paul But i ve seen that page b4.. it was the first i found but the first Testing... script says the image contains errors :| Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104730 Share on other sites More sharing options...
Alex Posted August 29, 2010 Share Posted August 29, 2010 Saying "it contains errors" isn't particularly useful to anyone trying to help you. What errors specifically, are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104732 Share on other sites More sharing options...
jcbones Posted August 29, 2010 Share Posted August 29, 2010 image.php <?php // Set the content-type header('Content-type: image/png'); $text = (isset($_GET['text'])) ? $_GET['text'] : exit(); $font = 'A.C.M.E._Explosive_Bold.ttf'; //location of your true type font. // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // Add some shadow to the text imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> test.html <img src="image.php?text=This_is_a_test" alt="test" /> Tell us how it goes. Make sure your font file exists, and has no spaces in it. Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104739 Share on other sites More sharing options...
litebearer Posted August 29, 2010 Share Posted August 29, 2010 Killer... I tested the link I gave (the tutorial), it works fine no errors. Soooo we need to see your code Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104740 Share on other sites More sharing options...
jcbones Posted August 29, 2010 Share Posted August 29, 2010 Killer... I tested the link I gave (the tutorial), it works fine no errors. Soooo we need to see your code I think he either has a space in his font file name, or his font file doesn't exist. I tried duplicating his error, and that was the only two ways I could get it to return that error. Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104744 Share on other sites More sharing options...
redarrow Posted August 29, 2010 Share Posted August 29, 2010 learn gd better off... http://php.net/manual/en/book.image.php Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104745 Share on other sites More sharing options...
Dragosvr92 Posted August 29, 2010 Author Share Posted August 29, 2010 Saying "it contains errors" isn't particularly useful to anyone trying to help you. What errors specifically, are you getting? alex.. the error is the one you usually get on a php image The image “http://localhost/Font%20Test/test.php” cannot be displayed, because it contains errors. thats what it says if i use the first example from paul s url ohhhhhhhh thank you bones ... the scripts seemd to be working ... the reason i was getting that error was because my font file had spaces i will play with it and reply if i need further support Quote Link to comment https://forums.phpfreaks.com/topic/211942-create-image-from-text/#findComment-1104842 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.