如何将使用 gd 创建的图像保存为 png-8?
它可以很好地保存为具有透明通道的 gif - 但我想使用 png-8。
此致,
啤酒威斯勒
Using imagesavealpha()
透明的背景颜色应该可以解决问题......
基于 dfilkovi 的代码:
<?php
// Create a new true color image
$im = new imagecreatetruecolor(100, 100);
// Fill with alpha background
$alphabg = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $alphabg);
// Convert to palette-based with no dithering and 255 colors with alpha
imagetruecolortopalette($im, false, 255);
imagesavealpha($im, true);
// Save the image
imagepng($im, './paletteimage.png');
imagedestroy($im);
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)