1
我使用GD覆蓋圖像上的一些文本(已經在我的服務器上)。我試圖將新圖像保存在服務器上。PHP/GD Library Imagettftext將圖像保存在服務器上併發送到瀏覽器
下面是我的代碼,但它所做的只是向瀏覽器顯示新圖像,並不會將其保存到服務器。
<?
//PHP's GD class functions can create a variety of output image
//types, this example creates a jpeg
header("Content-Type: image/jpeg");
$im = imagecreatefromjpeg($image_full);
$black = ImageColorAllocate($im, 255, 255, 255);
$copy_1_x = 10;
$copy_1_y = 20;
$copy_2_x = 10;
$copy_2_y = 20;
$copy_3_x = 10;
$copy_3_y = 20;
//writes text to image
Imagettftext($im, 12, 0, $copy_1_x, $copy_1_y, $black, 'verdana.ttf', $main_number);
Imagettftext($im, 12, 0, $copy_2_x, $copy_2_y, $black, 'verdana.ttf', $prime_number);
Imagettftext($im, 12, 0, $copy_3_x, $copy_3_y, $black, 'verdana.ttf', $legal);
//Creates the jpeg image and sends it to the browser
//100 is the jpeg quality percentage
Imagejpeg($im, '', 100);
ImageDestroy($im);
?>
[*嘆*](http://php.net/manual/en/function.imagejpeg.php) –
感謝實測值。我實際上已經看過頁面,但錯過了保存爲文件的例子。 – Denoteone