note 50809 deleted from function.imagettfbbox by googleguy

From: Date: Tue, 22 Oct 2013 10:16:29 +0000
Subject: note 50809 deleted from function.imagettfbbox by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196964@lists.php.net to get a copy of this message
Note Submitter: webmaster at funfragforce dot de ---- Here a little code snippet to align the text to horizontally center: <?php $insert = imagecreatefromgif("test.gif"); $text="TEST"; $font="arial.ttf"; //choose textcolor (black) $col=ImageColorAllocate ($insert, 0, 0, 0); //check width of the text $bbox=imagettfbbox (12, 0, $font, $text); $xcorr=0-$bbox[6]; $mase=$bbox[2]+$xcorr; //check width of the image $width=imagesx($insert); //calculate x coordinates for text $new=($width-$mase)/2; //write text imagettftext ($insert, 12, 0, $new, 50, $col, $font, $text); //output picture imagegif($insert,"",100); ?>

« previous php.notes (#196964) next »