cturner Posted September 29, 2007 Share Posted September 29, 2007 Is there a way to create a button to the length of the button's printing? Thanks in advance. Here is my code: $name1 = stripslashes($_POST['pagetitle']); $name2 = str_replace('%20', ' ', $name1); $name3 = strtoupper($name2); $pagetitle5 = stripslashes($_POST['pagetitle']); $pagetitle6 = str_replace("'", '', $pagetitle5); $pagetitle7 = str_replace('%20', '', $pagetitle6); $pagetitle8 = strtolower($pagetitle7); function makeimage($pagetitle8, $name3) { header("Content-type: image/jpeg"); $im = @imagecreate(110, 23) or die("Cannot Initialize new GD image stream."); $background_color = imagecolorallocate($im, 0, 57, 122); $text_color = imagecolorallocate($im, 255, 255, 255); imagestring($im, 3, 10, 5, $name3, $text_color); imagejpeg ($im, "images/".$pagetitle8."btn.jpeg"); imagedestroy($im); } makeimage($pagetitle8, $name3); Link to comment https://forums.phpfreaks.com/topic/71133-creating-buttons-to-the-length-of-the-printing-is-it-possible/ Share on other sites More sharing options...
tippy_102 Posted September 29, 2007 Share Posted September 29, 2007 You want the background colour the same length as the text? Discover the length of the text using ImageFontWidth ( http://ca.php.net/manual/en/function.imagefontwidth.php ) then make your background a few pixels wider. Link to comment https://forums.phpfreaks.com/topic/71133-creating-buttons-to-the-length-of-the-printing-is-it-possible/#findComment-357738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.