kusal Posted January 8, 2008 Share Posted January 8, 2008 Hi I want to convert a string that is retrieved from a mysql database to a image that contain the text. can I do this in PHP Thank you Link to comment https://forums.phpfreaks.com/topic/85037-solved-text-to-image/ Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 http://us3.php.net/manual/en/function.gd-info.php Link to comment https://forums.phpfreaks.com/topic/85037-solved-text-to-image/#findComment-433666 Share on other sites More sharing options...
kusal Posted January 8, 2008 Author Share Posted January 8, 2008 <?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); ?> how can I embed this png file into a html file or PHP file? Link to comment https://forums.phpfreaks.com/topic/85037-solved-text-to-image/#findComment-433770 Share on other sites More sharing options...
rhodesa Posted January 8, 2008 Share Posted January 8, 2008 1) put that code into it's own file...let's call it image.php 2) on your website, refer to it like you would a normal image: <img src="image.php" /> Link to comment https://forums.phpfreaks.com/topic/85037-solved-text-to-image/#findComment-433779 Share on other sites More sharing options...
kusal Posted January 8, 2008 Author Share Posted January 8, 2008 Thank you it works Link to comment https://forums.phpfreaks.com/topic/85037-solved-text-to-image/#findComment-433793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.