0
我試過其他的解決方案,但它沒有奏效,所以我粘貼在這裏我的代碼,可以複製,但不能用透明度保存它[透明部分變白]!合併透明PNG圖像與其他PNG圖像 - PHP
<?php
$dest = imagecreatefrompng('album.png');
imagealphablending($dest, true);
imagesavealpha($dest, true);
$offset = 10;
$friends = array ('captcha1.png', 'captcha2.png', 'captcha3.png', 'captcha4.png', 'captcha5.png', 'captcha6.png', 'captcha7.png', 'captcha8.png', 'captcha9.png');
$baby = array ('baby1.png', 'baby2.png', 'baby3.png', 'baby4.png');
$ids = getID(0, count($friends)-1, 3);
for ($i=0;$i<3;$i++)
{
$index = $ids[$i];
$src = imagecreatefrompng($friends[$index]);
$offsetY = imagesx($src);
imagecopymerge($dest, $src, 10, $offset, 0, 0, $offsetY, imagesy($src), 100);
$src = imagecreatefrompng($baby[rand(0,3)]);
imagealphablending($src, true);
imagesavealpha($src, true);
imagecopymerge($dest, $src, ($offsetY + 250), $offset, 0, 0, imagesx($src),imagesy($src), 99);
$offset = $offset + imagesx($src) + 45;
}
header('Content-Type: image/png');
imagealphablending($dest, true);
imagesavealpha($dest, true);
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
function getID($min, $max, $quantity) {
$numbers = range($min, $max);
shuffle($numbers);
return array_slice($numbers, 0, $quantity);
}
?>
我也試圖與** imagealphablending($ SRC,FALSE); ** – Sourav 2011-06-03 13:56:33