PHP转换为透明的不会让它变得透明

时间:2015-05-04 18:40:45

标签: php image transform photo photoshop

我尝试将 imageA.png 透明,然后使用imagecopy函数将其合并到另一个完全透明的图像,但合并后, imageA.png 变成白色背景而不是透明

  • 我相信这是因为它没有正确转换为透明

这是我用过的东西 这是一个独立的文件,用于将图像转换为透明(工作原理):

$img = imagecreatefrompng("imageA.png");
$white = imagecolorallocate($img, 255, 255, 255);
imagecolortransparent($img, $white);
header('Content-Type: image/png');
imagepng($img);

这个是将上面的结果与另一个透明图像合并

$src = imagecreatefrompng("imageA_transparent.png");
$dest = imagecreatefrompng('another_transparent_image.png');
imagesavealpha($dest, true);
imagealphablending($dest, true);

imagecopy($dest, $src, 0, 0, 0, 0, 400, 400);

结果是imageA_transparent.png变为白色背景,而第二个透明使用的图像实际上是透明的(another_transparent_image.png)

  • 我尝试使用普通的photoshopped透明图像并且工作没有问题

  • 我尝试将imagesavealphaimagealphablending$src同时使用,但没有效果

  • 在使用imagecopy
  • 之前,两张图片都是正确透明的

**最后,当我试图打开imageA_transparent.png(php生成的透明图像),在Photoshop中时,它出现了白色背景和锁定图层,这意味着PHP没有&# 39;正确地将它转换为透明/ png(我相信)

0 个答案:

没有答案
相关问题