note 11807 deleted from function.imagettfbbox by didou

From: Date: Fri, 15 Aug 2003 22:10:05 +0000
Subject: note 11807 deleted from function.imagettfbbox by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54267@lists.php.net to get a copy of this message
Note Submitter: php-general@lists.php.net ---- Here is some code I've used to create an image with text centered left to right. I have still yet to figure out how to get it centered top to bottom. If anyone can figure out how to get a pixel height on a text box, please post. <?php $imagewidth = 100; $imageheight = 20; $fontsize = 12; $myimg=ImageCreate($imagewidth, $imageheight); $col1=ImageColorAllocate($myimg, 255, 0, 0); $col2=ImageColorAllocate($myimg, 255, 255, 255); $thetextbox = ImageTTFBBox ($fontsize, 0, "./ttfonts/arialnb.ttf", "My Button"); $textwidth = (($thetextbox[4] + $thetextbox[2]) / 2) - (($thetextbox[6] + $thetextbox[0]) / 2); $xpos = ($imagewidth - $textwidth) / 2; $ypos = 14; ImageTTFText ($myimg, $fontsize, 0, $xpos, $ypos, $col2, "./ttfonts/arialnb.ttf", "My Button"); ImagePNG($myimg, "myimg.png"); ImageDestroy($myimg); ?> <img src="myimg.png" border=0>

« previous php.notes (#54267) next »