2013-05-03 17 views
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的新手,請幫助我。

回答

1

使用PHP的換行功能看: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); 
+0

喬本:它的作品!非常感謝。 – 2013-05-05 04:44:42

相關問題