【发布时间】:2015-07-13 13:25:17
【问题描述】:
我需要将两个图像合并在一起并向其中添加文本。但是当代码输出我得到黑色背景。当我删除“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);
【问题讨论】:
标签: php