Answer the question
In order to leave comments, you need to log in
Why does saving the alpha channel in GD not work?
It is necessary to save the alpha channel of the image (.png).
Tried this code:
$up = ImageCreateFrompng('up.png');
imagealphablending($up, false);
imagesavealpha($up, true);
imagecopy($pic, $up, 200, 200, 0, 0, 145, 343);
Answer the question
In order to leave comments, you need to log in
I solved the problem by the fact that it was necessary to save both images in PNG-24.
Probably need to include alpha in $pic before this
$up = ImageCreateFrompng('up.png');
$pic = imagecreatetruecolor(400, 400);
imagealphablending($pic, false);
// imagesavealpha($pic, true); // true alpha channel
imagecopy($pic, $up, 200, 200, 0, 0, 145, 343);//, 145, 343
imagesavealpha($pic, true); // PNG-24
imagepng($pic, 'pic.png');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question