0
imagettftext를 사용하여 PHP로 만든 이미지에서 텍스트를 가운데에 맞출 수있는 방법이 확실하지 않습니다.PHP 이미지의 가운데 맞춤 텍스트
다음header('Content-Type: image/png');
$im = imagecreatetruecolor(260, 180);
$background = imagecolorallocate($im, 0, 0, 255);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 60, 153, 181);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 200, $white);
$text = $_GET['tname'];
$font = 'OpenSans-Semibold.ttf';
imagettftext($im, 20, 0, $x+1, $y+1, $grey, $font, $text);
imagettftext($im, 20, 0, $x, $y, $black, $font, $text);
imagepng($im);
imagedestroy($im);
사용 [imagetttfbbox] (http://php.net/manual/en/function.imagettfbbox.php) 텍스트의 크기를 계산하려면 상자에서 이미지의 위치를 계산하십시오. –
예제를 제공해 줄 수 있습니까? 나는 설명서를 읽으려고했지만 반환 된 결과에 대한 부분을 정말로 이해하지 못했습니다. – icecreamscoop