I have a question related to the GD library on PHP. I can't add a transparent image to the canvas in a way that preserves the transparency.
Here is the code that I used
$canvas = imagecreatetruecolor(4000, 4000);
imagealphablending($canvas, false);
imagesavealpha($canvas, true);
$color = imagecolorallocatealpha($canvas, 255, 250, 156, 0);
imagefill($canvas, 0, 0, $color);
$mask = imagecreatefrompng('mask.png');
imagealphablending($mask, false);
imagesavealpha($mask, true);
imagecopyresampled($canvas, $mask, 500, 500, 0, 0, 1500, 1500, imagesx($mask), imagesy($mask));
header("Content-type: image/png");
imagepng($canvas);
exit;
As you can see, the image with the dog has a white background, but I need a yellow background (like on the canvas) instead of this white background.
Please write what is my mistake. Thank you very much.