使用Php将2 png-24透明图像组合在一起

Dan*_*ing 0 php image

您好我正在尝试组合两个透明的png-24图像,大小400宽,150高.

背景:["http://www.fenixflame.net/Background-Zanaris-24.png"][1]

我要覆盖的图像背景:["http://www.fenixflame.net/Bandos-Slayer-24.png"][2]

我尝试使用PHP覆盖透明图像,但只使用png-8图像.由于图像无法正确渲染,因此无法使用png-8.

编辑:我试过的代码:

    $image = imagecreatefrompng("http://www.fenixflame.net/Background-Zanaris-24.png");  
$frame = imagecreatefrompng("http://www.fenixflame.net/Bandos-Slayer-24.png");
//
//imagealphablending($frame,true);
//
 $insert_x = imagesx($frame); 
  $insert_y = imagesy($frame); 
  imagecopymerge($image,$frame,0,0,0,0,$insert_x,$insert_y,100); 
//
//# Save the image to a file imagepng($image, '/path/to/save/image.png');
 imagepng($image, "/home1/fenixfla/public_html/Images/Signatures/NewImageBG.png");
//
//# Output straight to the browser.
 imagepng($image); 
//
Run Code Online (Sandbox Code Playgroud)

sug*_*nan 8

我在这个链接scitam.com上写了一个小例子来合并两个透明图像

尝试这个代码它工作正常.


    $width = 200;
    $height = 200;

    $base_image = imagecreatefromjpeg("base.jpg");
    $top_image = imagecreatefrompng("top.png");
    $merged_image = "merged.png";

    imagesavealpha($top_image, true);
    imagealphablending($top_image, true);

    imagecopy($base_image, $top_image, 0, 0, 0, 0, $width, $height);
    imagepng($base_image, $merged_image);