在生产环境中有一件奇怪的事情。在 imagecopyresampled 之后,Alpha 通道会覆盖底层的非透明部分。
在开发中它按预期工作:
但在生产中,我得到了这个:
$bubble = imagecreatefrompng($bubblePath);
imagealphablending($bubble, true);
imagesavealpha($bubble, true);
$icon = imagecreatefrompng($iconPath)
imagealphablending($icon, true);
imagesavealpha($icon, true);
imagecopyresampled($bubble, $icon, ($bubbleWidth - $newIconWidth) / 2, 200 - $newIconHeight / 2, 0, 0, $newIconWidth, $newIconHeight, $iconWidth, $iconHeight);
imagepng($bubble, "./result.png");
我的应用程序使用 docker,所以环境已经构建并且应该是一样的。PHP 8.0.10