[英]Image Overlay in PHP; Black Background?
当我使用GD库在php中执行图像叠加时,总是得到黑色背景,但是,所有图像均正确叠加。 有人可以帮忙吗?
<?php
$images = array( $_GET['color'], $_GET['face'], $_GET['hat'] );
$img = imagecreatetruecolor(58, 75);
imagealphablending($img, true);
imagesavealpha($img, true);
imagecolorallocate($img, 255, 205, 255);
imagecolorallocate($img, 255, 255, 255);
imagecolortransparent($img, $white);
imagefilledrectangle($img, 0, 0, $imgWidth, $imgHeight, $white);
foreach($images as $fn) {
$cur = imagecreatefrompng($fn);
imagealphablending($cur, true);
imagesavealpha($cur, true);
imagecopy($img, $cur, 0, 0, 0, 0, 58, 75);
imagedestroy($cur);
}
header('Content-Type: image/png');
imagepng($img);
?>
// Create an image
$img = imagecreatetruecolor($imgWidth, $imgHeight);
$white = imagecolorallocate($img, 255, 255, 255);
// Make the background white
imagefilledrectangle($img, 0, 0, $imgWidth, $imgHeight, $white);
...有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.