我使用此代码从另一个png图像创建图像,默认情况下背景为黑色。我的问题是如何设置透明背景?
$input = imagecreatefrompng('image.png');
$output = imagecreatetruecolor(50, 50);
imagecopy($output, $input, 4,0, 8,8, 8,8);
imagecopy... etc.
header('Content-Type: image/png');
imagepng($output);
有没有简单的方法可以做到这一点?谢谢
最佳答案
设置给定图像中的透明颜色。
int imagecolortransparent ( resource $image [, int $color ] )
这是link
关于具有透明背景的PHP imagecopy,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7728508/