什麼看似簡單,是不是:(透明PNG超過JPG在PHP
我試圖像水印(透明的PNG)的圖像(JPG格式)上添加一些東西。 這是代碼我使用的是:
$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定位在正確的地方,上面everythig留下的是好(JPG被複制),但一切是黑色
我試過將imagesavealpha和imagealphablending設置爲false,沒有任何區別。
您可以在http://ekstrakt.selfip.com/photobomb/image.php
我已搜索周圍的網看到生成的圖像,我無法找到一個解決方案。
任何幫助表示讚賞。
您還必須在$ bottom_image上啓用alphablending。 –