0

been messing with imagestring trying to change font & font size but i really dont have a clue, i'm new to php and have worked on some code that i came across on a forum and have made it work for me just need to find a way to change font and font size but everything i've tried hasn't given me a good outcome.. any solutions? Please bare in mind i'm new to php and if you could explain as much as possible for your answer thank you so much

$im = imagecreatefrompng("image.png");
// if there's an error, stop processing the page:
if(!$im)
{
    die("");
}
// define some colours to use with the image
$black = imagecolorallocate($im, 80, 77, 77);
$font = 'cour.ttf';
// get the width and the height of the image
$width = imagesx($im);

$height = imagesy($im);



$textt = $_GET['textt'];
$dealer = $_GET['dealer'];
$purchase = $_GET['purchase']; 
$name = $_GET['name'];
$address = $_GET['address'];
$address1 = $_GET['address1'];

// store the text we're going to write in $textt
putenv('GDFONTPATH=' . realpath('cour.ttf'));


// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($textt) )/2;
$leftTextPos = ( $width - imagefontwidth($font)*strlen($dealer) )/2;
// finally, write the string:

imagestring($im,$font,$leftTextPos-210,$height-295,$textt,$black);
imagestring($im,$font,$leftTextPos-210,$height-165,$dealer,$black);
imagestring($im,$font,$leftTextPos-200,$height-115,$purchase,$black);
imagestring($im,$font,$leftTextPos-130,$height-70,$name,$black);
imagestring($im,$font,$leftTextPos-100,$height-50,$address,$black);
imagestring($im,$font,$leftTextPos-00,$height-50,$address1,$black);
// output the image
// tell the browser what we're sending it
Header('Content-type: image/png');
// output the image as a png
imagepng($im);
// tidy up
imagedestroy($im);
?>
4

1 回答 1

0

您应该尝试使用imagettftext函数。

于 2013-05-05T18:47:37.200 回答