Php WEBP重采样丢失透明度
如果我对透明的WEBP图像重新采样,背景颜色将为黑色。metodes帮助我实现PNG,而不是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
$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