我在使用cakePHP应用程序中的jQuery Uploadify插件时遇到了问题。
除了我在上传透明图片时遇到的一个问题之外,一切都很好。每当我上传透明的图像时,图像的透明区域被存储为黑色。
我怀疑这可能是Uploadify插件没有正确加载图像的alpha通道造成的,但我不能确定。
发布于 2012-01-12 20:04:45
感谢您的贡献。
我已经解决了这个问题,我必须改变我用来上传图像的图像组件的resize函数中的代码位。
我必须把一些代码放在前面:
imagecopyresampled($imgDes, $imgSrc, 0, 0, 0, 0, $width, $height, $trueWidth, $trueHeight);
新代码如下:
if($fileType == 'png' || $fileType == 'gif') {
imagealphablending($imgDes, false);
imagesavealpha($imgDes,true);
$transparent = imagecolorallocatealpha($imgDes, 255, 255, 255, 127);
imagefilledrectangle($imgDes, 0, 0, $width, $height, $transparent);
}将此新代码放在图像组件的以下函数中:
function resizeImg($imgName, $size, $fileName)https://stackoverflow.com/questions/8815475
复制相似问题