2017-05-17 41 views
1

我能夠創建圖像,但無法在圖像上寫入任何東西。使用php將文本轉換爲圖像

我也沒有收到任何錯誤消息。這裏是我的代碼:

$ouput ="uploads/jersey/img1.jpg"; 
$x=720; 
$y=480; 
$image = imagecreate($x,$y); 
$white = imagecolorallocate($image,95,73,255); 
$black = imagecolorallocate($image,0,0,0); 
$white = imagecolorallocate($image,255,255,255); 
$fs =40; 
$rotation = 0; 
$origin_x = 20; 
$origin_y = 20; 
$font = "./arial.ttf"; 
imagefttext("$image",16,0,0,16,$black,$font,"test"); 
imagejpeg($image,$ouput); 

你能幫我解決這個問題嗎?

+0

難道這是一個權限的事情? – cfnerd

+0

如果你問一些問題,確保你使用了一些對每個人都容易理解的詞組。不要像你那麼短。 –

回答

0

更改此:

imagefttext("$image",16,0,0,16,$black,$font,"test"); 

要這樣:

imagefttext($image,16,0,0,16,$black,$font,"test"); 

以下是錯誤消息:

PHP Warning: imagefttext() expects parameter 1 to be resource, string given in /tmp/index.php on line 15 

你在你的腳本的正確的地方尋找錯誤消息?從命令行運行您的腳本或查看您的Web服務器的錯誤日誌。它會在某個地方像/var/log/httpd/error_log