Forum Moderators: coopster
i have the following code to write text on an image
$myImage = imagecreatefromjpeg('certificate.jpg');
$black=imagecolorallocate($myImage, 0, 0 ,0);
imagefttext($myImage, 16, 0, 250, 140, $black, "arialbd.ttf",$_REQUEST['cname']);
imagefttext($myImage, 12, 0, 290, 160, $black, "arialbd.ttf","STATE");
imagefttext($myImage, 12, 0, 300, 180, $black, "arialbd.ttf","COUNTRY");
header("Content-type: image/jpeg");
imagejpeg($myImage);
but if the name is say,
charlie it will become in the middle of the image but if the name is long like Angelina Jolie it starts at the fixed width and height and is pushed towards the right side of the image..
i want that the script automatically writes the text in the exact centre of the image,
like in html we do
<center>name</center> so whatever the text length is it will come in the centre of the page..
is there any option in php to write the text in the centre of the image?