使用带有字体缩放功能的GD库在图像上显示文本中心

时间:2019-06-15 16:12:09

标签: php css gd

所以我正在创建带有文本的图像生成器。

我希望文本始终位于图像的中间,如果可能的话,可以使用字体缩放。但是我不知道该怎么做。

截屏: https://i.stack.imgur.com/avYaQ.jpg

//the default "quote" settings 
$myquotetext = '';
$fontsizemyquote = "70";
$ttfmyquote = "assets/myfonts/IMPACT.TTF";
//font positioning and color can be changed from the index page. Find $colorsauthor = imagecolorallocate($startimage, 0, 0, 0) and make any necessary adjustments. 


//QTP myquote
$fontrotation = "0";
$str = wordwrap($myquotetext, 40, "\n", true);
$x = "130";
$y = "320";
$colormyquote = imagecolorallocate($startimage, 0, 0, 0);
imagettftext($startimage, $fontsizemyquote, $fontrotation, $x, $y, $colormyquote, $ttfmyquote, $str);

0 个答案:

没有答案