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! Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/ 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 Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554533 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! Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554549 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? Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554552 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"; Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554554 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? Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554558 Share on other sites More sharing options...
DarkWater Posted June 1, 2008 Share Posted June 1, 2008 $text = $_GET['text']; O_O Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554559 Share on other sites More sharing options...
prudens Posted June 1, 2008 Author Share Posted June 1, 2008 tried it, doesn't work >< Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554569 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']; ?> Link to comment https://forums.phpfreaks.com/topic/108181-php-text-image/#findComment-554623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.