在图像文件夹中,我有一个notfound.php文件
<?php
header('Content-type: image/png');
$im = imagecreatefrompng('simnotfound.png');
imagepng($im);
imagedestroy($im);
?>图像大小为256 x 256。notfound.php页面显示一个256x256的黑色正方形。尽管图像并不全是黑色的。它只是一些透明背景上的黑色文本。
修复方法是
<?php
header('Content-type: image/png');
$im = imagecreatefrompng('simnotfound.png');
imagealphablending($im, true); // setting alpha blending on
imagesavealpha($im, true); // save alphablending setting (important)
imagepng($im);
imagedestroy($im);
?>发布于 2011-03-13 12:03:22
再次创建白色背景的图像文件以检查是否正确读取,如果是-问题是您的透明背景
还可以尝试使用其他文件,以消除读取此特定文件时出现的问题
发布于 2015-08-21 17:50:58
bool imagesavealpha ( resource $image , bool $saveflag )imagesavealpha设置标志以在保存PNG图像时保存完整的alpha通道信息(与单色透明度相反
https://stackoverflow.com/questions/5287292
复制相似问题