我在嘗試合併文本字符串與圖像。我在Stackoverflwo上找到了關於如何執行此操作的示例,但是當我加載腳本時,所有的操作都是亂碼。我認爲這是一個字體問題,但我不知道如何解決這個問題。我已經將True type字體(arial)放在與腳本相同的目錄中。建議?這裏是我的代碼:將圖像與圖像合併
<?php
$im = imagecreatefromjpeg('image.jpg');
//The numbers are the RGB values of the color you want to use
$black = ImageColorAllocate($im, 255, 255, 255);
//The canvas's (0,0) position is the upper left corner
//So this is how far down and to the right the text should start
$start_x = 10;
$start_y = 20;
$font = 'arial.ttf';
Imagettftext($im, 12, 0, $start_x, $start_y, $black, $font, 'text to write');
//Creates the jpeg image and sends it to the browser
//100 is the jpeg quality percentage
Imagejpeg($im, '', 100);
ImageDestroy($im)
?>
謝謝,這是做的伎倆,非常豐富! – user1009453 2012-03-05 15:17:34
不客氣。在附註中,以小寫形式寫出函數名稱被認爲是很好的做法。 – kba 2012-03-05 15:19:21