Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WEBP重采样丢失透明度_Php_Gd_Webp - Fatal编程技术网

Php WEBP重采样丢失透明度

Php WEBP重采样丢失透明度,php,gd,webp,Php,Gd,Webp,如果我对透明的WEBP图像重新采样,背景颜色将为黑色。metodes帮助我实现PNG,而不是WEBP 例如: $thumb = imagecreatetruecolor($newWidth, $newHeight); imagecolortransparent($thumb, imagecolorallocate($thumb, 0, 0, 0)); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $newWidth, $newHeight, $wi

如果我对透明的WEBP图像重新采样,背景颜色将为黑色。metodes帮助我实现PNG,而不是WEBP

例如:

$thumb = imagecreatetruecolor($newWidth, $newHeight);
imagecolortransparent($thumb, imagecolorallocate($thumb, 0, 0, 0));
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);

可能是您使用的是旧版本的Gd吗?在保存webp时,Gd的旧版本似乎放弃了alpha通道。关于这个问题的更多信息,请参见:

提议的解决办法:

  • 升级Gd
  • 告诉用户升级Gd
  • 使用其他工具,如Imagick或VIP
你能透露你的Gd和PHP版本吗