PHP+GD: imagecopymerge not retaining PNG transparencies

自古美人都是妖i 提交于 2019-11-29 04:45:57

This works perfectly for me:

$img1 = imagecreatefrompng('red.png');
$img2 = imagecreatefrompng('blue.png');

$x1 = imagesx($img1);
$y1 = imagesy($img1);
$x2 = imagesx($img2);
$y2 = imagesy($img2);

imagecopyresampled(
    $img1, $img2,
    0, 0, 0, 0,
    $x1, $y1,
    $x2, $y2);

imagepng($img1, 'merged.png', 0);

PHP Version 5.3.2
GD Version 2.0
libPNG Version 1.2.42

Have you tried saving the image to a file and checking that?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!