prudens Posted June 1, 2008 Share Posted June 1, 2008 Hi, I want to use PHP to generate simple anti-aliased texts based on user inputs. Where can I find more information about it? Thanks! Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted June 1, 2008 Share Posted June 1, 2008 http://www.php.net/imagettftext And if you can't figure out how to use it I can help you, I'm vary good with GD Quote Link to comment Share on other sites More sharing options...
prudens Posted June 1, 2008 Author Share Posted June 1, 2008 Do I need special libraries? I tried: <?php // Set the content-type header("Content-type: image/png"); // 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); // The text to draw $text = 'Testing...'; // Replace path by your own font path $font = 'arial.ttf'; // 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); ?> And I put "arial.ttf" in my directory... doesn't work! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 1, 2008 Share Posted June 1, 2008 You usually want to make the header call RIGHT before the imagepng() call. And do you have GD installed? Quote Link to comment Share on other sites More sharing options...
prudens Posted June 1, 2008 Author Share Posted June 1, 2008 oh, I ended up having put the font dir like: $font_dir = "/home/etc/etc/website/font.ttf"; Quote Link to comment Share on other sites More sharing options...
prudens Posted June 1, 2008 Author Share Posted June 1, 2008 Say I want to do something like write.php?text='blahblahblah' How do I make the imagettftext() read the text variable and write? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 1, 2008 Share Posted June 1, 2008 $text = $_GET['text']; O_O Quote Link to comment Share on other sites More sharing options...
prudens Posted June 1, 2008 Author Share Posted June 1, 2008 tried it, doesn't work >< Quote Link to comment Share on other sites More sharing options...
c-drive Posted June 1, 2008 Share Posted June 1, 2008 Are you sure you aren't setting $text twice? You need to comment out your original variable definition. Like this: <?php //$text = 'Testing...'; $text = $_GET['text']; ?> Quote Link to comment 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.