0

如何使用 php wideimage 将长文本写入小图像?

这是我使用的php代码,

$bg = WideImage::load("fbpostbg.png");
$final= $bg ->resize(400, 400);
$canvas = $final ->getCanvas();
$canvas->useFont('verdana.ttf', 14, $final->allocateColor(000, 000, 000));
$canvas->writeText('left +10', 'top +10', 'This is the text that I need to write to the above image, which is quite long...');

$final->output('jpg', 90);  

这会在图像画布之外输出一些文本并且看不到......
我需要在我们写入图像的文本中进行自动换行,并且需要获取包含全文的图像。

我是 WideImage 的新手,请帮助我。

4

1 回答 1

1

use php's wordwrap function see: http://php.net/manual/en/function.wordwrap.php

 $wrappedtext = wordwrap('This is the text that I need to write to the above image, which is quite long...', 60, "\n");
 $canvas->writeText('left +10', 'top +10',$wrappedtext);
于 2013-05-03T21:38:15.330 回答