note 86593 modified in function.imagecolortransparent by danbrown

From: Date: Sat, 25 Oct 2008 05:36:42 +0000
Subject: note 86593 modified in function.imagecolortransparent by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145734@lists.php.net to get a copy of this message
How to center your text both vertically and horizontally in a GD image: <?php //get box size $box = imagettfbbox($titlesize, 0, $titlefont, $title); //Find out the width and height of the text box $textW = $box[2] - $box[0]; $textH = $box[5] - $box[3]; // Calculate the positions $positionLeft = ($width - $textW)/2; $positionTop = (($height - $textH)/2); // Add some text if($align=="center"){ imagettftext($pic, size, angle, $positionLeft, $positionTop, colour, font, message); ?> --was-- How to center your text both vertically and horizontally in a GD image: //get box size $box = imagettfbbox($titlesize, 0, $titlefont, $title); //Find out the width and height of the text box $textW = $box[2] - $box[0]; $textH = $box[5] - $box[3]; // Calculate the positions $positionLeft = ($width - $textW)/2; $positionTop = (($height - $textH)/2); // Add some text if($align=="center"){ imagettftext($pic, size, angle, $positionLeft, $positionTop, colour, font, message); http://php.net/manual/en/function.imagecolortransparent.php

« previous php.notes (#145734) next »