我需要將兩個圖像合併在一起並向其中添加文本。但是,當代碼輸出我得到黑色背景。當我刪除「imagecopymerge」功能,我看到白色背景。imagecopymerge獲取白色背景而不是黑色
$firstUrl = '1.jpg';
$secondUrl = "2.jpg";
$a = getimagesize ($firstUrl);
$x = 320;
$y = $a[1]+88;
$image = imagecreatetruecolor($x, $y);
$white = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image, 0, 0, $x, $y, $white);
$first = imagecreatefromjpeg($firstUrl);
$second = imagecreatefromjpeg($secondUrl);
imagecopymerge($image,$first,0,0,0,0, $x, $y,100);
imagecopymerge($image,$second,$a[0]-70,$a[1]+10,0,0, 60, 60,100);
$text_color = imagecolorallocate($image, 51, 51, 51);
$font = 'a.ttf';
imagettftext($image, 12, 0, 10, $a[1]+30, $text_color, $font, "text");
header("Content-Type: image/png");
imagepng($image);