Php ile birden saydam PNG görüntüleri birleştirerek

0 Cevap php

I'm having a slight problem merging multiple transparent pngs on top of each other. I'm trying to create a tool that designs a belt on the screen for the user allowing them to select a strap, buckle, and design crease.

The tool will merge three different images into one to create one preview image. When I run the code below it creates the strap image, adds the buckle correctly but a black box shows up on the right side of the strap image looking about the same size as the buckle image. I can't figure what is the problem.

Bu görüntüler yüzden bariz eksik olabilir kullanarak php ile yaptığım ilk çalışma olduğunu. Herkes bana yardımcı olabilir eğer ben minnettar olacaktır. şimdiden teşekkürler!

header('Content-type: image/png');
$strap = imagecreatefrompng("images/straps/DBR.png");
$w = imagesx($strap);
$h = imagesy($strap);

imagealphablending($strap,true);

$buckle = imagecreatefrompng("images/buckles/" . $buckle . ".png");
imagealphablending($buckle,true);

$crease = imagecreatefrompng("images/skull.png");
imagealphablending($crease,true);


imagecopy($strap,$buckle,200,0,0,0,$w,$h);
imagecopy($strap,$crease,0,0,0,0,$w,$h);

 //imagecopy($photo2,$crease,200,0,0,0,$w,$h);
// fill the image background with white

imagepng($strap); 

imagedestroy($strap);
imagedestroy($buckle);

UPDATE: This is my current source code

$strap = imagecreatefrompng("images/straps/DBR.png");
$w = imagesx($strap);
$h = imagesy($strap);

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


$buckle = imagecreatefrompng("images/buckles/" . $buckle . ".png");

imagealphablending($buckle,false);
imagesavealpha($buckle, true);

$crease = imagecreatefrompng("images/skull.png");

imagealphablending($crease,false);
imagesavealpha($crease, true);

imagecopy($strap,$buckle,200,0,0,0,$w,$h);
imagecopy($strap,$crease,0,0,0,0,$w,$h);

imagepng($strap); 

imagedestroy($strap);
imagedestroy($buckle);

0 Cevap