【发布时间】:2011-12-20 14:21:21
【问题描述】:
看起来很简单,其实不是:(
我正在尝试在图像 (jpg) 上添加水印(透明 png)之类的东西。 这是我正在使用的代码:
$width = 800;
$height = 600;
$bottom_image = imagecreatefromjpeg("portrait1.jpg");
$top_image = imagecreatefrompng("man2.png");
imagesavealpha($top_image, true);
imagealphablending($top_image, true);
imagecopy($bottom_image, $top_image, 200, 200, 0, 0, $width, $height);
header('Content-type: image/png');
imagepng($bottom_image);
当我合并图像时,png位于正确的位置,它上面和左边的一切都很好(复制了jpg),但其他一切都是黑色的。
我尝试将imagesavealpha和imagealphablending设置为false,没有任何区别。
您可以在http://ekstrakt.selfip.com/photobomb/image.php看到生成的图像
我已经在网上搜索了,我找不到解决方案。
感谢任何帮助。
【问题讨论】:
-
您还必须在 $bottom_image 上启用字母混合。
标签: php image png transparency php-gd