MaxEvans Posted February 1, 2008 Share Posted February 1, 2008 I'm pretty much a beginner here. But I've gotten the hang of some things. I just need some pointers. http://www.maximum-voltage.com/Userbar%20Generator/heart.php Something I'm working on for my site. I got it all the way I want it.. but I want to know if it's possible to keep the text completely centered in the image. Depending on how many characters are put in, it moves off to the side. I want to make it completely centered, if it's possible. And is it possible to create a stroke on the text. Or would I have to edit the font file? Link to comment https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/ Share on other sites More sharing options...
pdkv2 Posted February 1, 2008 Share Posted February 1, 2008 show the code are you using GB lib. ? Link to comment https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/#findComment-455068 Share on other sites More sharing options...
MaxEvans Posted February 1, 2008 Author Share Posted February 1, 2008 <?php error_reporting(E_ALL ^ E_NOTICE); session_start(); header("Content-type: image/png"); if ($_SESSION["message"]){ $message = $_SESSION["message"]; }else{ $message = $_GET['message'];} $im = imagecreatefrompng("Heart1.png"); $message_width = imagettfbbox(10, 0, "visitor.ttf", $message); $message_start = (350 - ($message_width[2] + 123)); $color = imagecolorallocate($im, 0, 0, 0); imagettftext($im, 10, 0, $message_start, 14, $color, "visitor.ttf", $message); imagepng($im); imagedestroy($im); ?> That's the code. Link to comment https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/#findComment-455069 Share on other sites More sharing options...
pdkv2 Posted February 1, 2008 Share Posted February 1, 2008 check this <?php error_reporting(E_ALL ^ E_NOTICE); session_start(); header("Content-type: image/png"); if ($_SESSION["message"]){ $message = $_SESSION["message"]; }else{ $message = $_GET['message'];} $im = imagecreatefrompng("Heart1.png"); //$message_width = imagettfbbox(10, 0, "visitor.ttf", $message); //$message_start = (350 - ($message_width[2] + 123)); //$color = imagecolorallocate($im, 0, 0, 0); //imagettftext($im, 10, 0, $message_start, 14, $color, "visitor.ttf", $message); $text_color = imagecolorallocate($im, 20, 211, 123); $imgx = (imagesx($im) - 7.5 * strlen($message)) / 2; $imgy = (imagesy($im)/4) ; imagestring($im, 3, $imgx, $imgy, $message, $text_color); imagepng($im); imagedestroy($im); ?> Link to comment https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/#findComment-455079 Share on other sites More sharing options...
MaxEvans Posted February 1, 2008 Author Share Posted February 1, 2008 That works perfectly for centering the text. But the font isn't visitor anymore. How do I get it to use that font? From the tff, like it was. Link to comment https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/#findComment-455082 Share on other sites More sharing options...
MaxEvans Posted February 1, 2008 Author Share Posted February 1, 2008 Anyone know? I looked through references and I can't figure it out. :-\ Link to comment https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/#findComment-455605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.