下面是在php中動態生成圖像的代碼。我想在這個動態創建的圖像中添加一些圖像。我已經用imagecopy嘗試過我的運氣,但是 失敗了,因爲我認爲它處理已經創建的圖像以將圖像複製到另一個圖像上。所以請儘快幫助。提前致謝。 :)如何在php中動態生成的圖像中添加來自某個源文件的jpeg圖像
<?php
$my_img = imagecreate(1200, 630);
$background = imagecolorallocate($my_img, 2,144,162);
$text_colour = imagecolorallocate($my_img, 255, 255, 0);
$text_colour1 = imagecolorallocate($my_img, 255, 255, 255);
$line_colour = imagecolorallocate($my_img, 128, 255, 0);
$font='C:\Windows\Fonts\ARLRDBD.ttf';
imagettftext($my_img, 48, 0, 450, 100, $text_colour, $font,"Hello World");
$font1='C:\Windows\Fonts\Arial.ttf';
imagettftext($my_img, 32, 0, 650, 160, $text_colour1, $font1,Hello World");
imagettftext($my_img, 32, 0, 500, 300, $text_colour1, $font1,"Hello World");
imagettftext($my_img, 32, 0, 560, 440, $text_colour1, $font1,"Hello World");
header("Content-type: image/png");
imagepng($my_img);
imagepng($my_img,'Ethers.png');
imagecolordeallocate($text_colour);
imagecolordeallocate($text_colour1);
imagecolordeallocate($background);
imagedestroy($my_img);
header('Content-Type: image/png');
imagedestroy($my_img);
?>
你也有圖像編輯功能,如http://www.php.net/manual/en/ref.image.php –