Answer the question
In order to leave comments, you need to log in
How to overlay an image on a png image in php?
Hello!
I am writing a script that overlays several images on top of each other. There was a problem. When overlaying a png, for some reason it overlaps another png along with its transparency.
$png1 = imagecreatefrompng('1.png');
imagealphablending($png1, false);
imagesavealpha($png1, true);
$png2 = imagecreatefrompng('2.png');
imagealphablending($png2, false);
imagesavealpha($png2, true);
// Накладываем
imagecopy($png1, $png2, 43, 95, 0, 0, imagesx($png2), imagesy($png2));
// отображаем изображение
$result = imagepng($png1);
//И в $result картинку выводим с хедером
Answer the question
In order to leave comments, you need to log in
If I understand the problem correctly:
imagealphablending($png1, false)
imagealphablending($png2, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question