I need to merge two images using PHP. The background image is JPG and the second image is PNG and has a transparent background. I've tried several ways and suggestions that I've seen on the internet, but none works. See what my code looks like:
$audible_fundo = imagecreatefromjpeg('audible.jpg');
$audible_icon = imagecreatefrompng('icon.png');
imagealphablending($audible_icon, false);
imagesavealpha($audible_icon, true);
imagecolortransparent($audible_icon);
imagecopymerge($audible_fundo, $audible_icon, 700, 300, 0, 0, 479, 180, 100);
imagepng($audible_fundo);
See the result: Image Merge Result
The image on the right (png) has a white background and a black section. I need to leave it with the transparent background, like the original. How can I resolve this?