【发布时间】:2012-11-26 15:25:58
【问题描述】:
我对 PHP 图像和 Web 浏览器有一个奇怪的问题..
首先,我知道 PHP 是一种服务器端语言,它与浏览器无关,但为什么我的脚本可以在 Firefox、Safari 或 Chrome 上运行,而不是在 Internet Explorer 上运行??
function image_effect_negative($counter,$file,$layer){
$image = "../images/tmp/$file/layer_$layer.png";
$img = imagecreatefrompng($image);
if($layer == 0){
$path = "../images/tmp/$file/$counter".".jpg";
}else{
$path = "../images/tmp/$file/layer_$layer.png";
$path2 = "../images/tmp/$file/tmp_layer_$layer.png";
}
if($img && imagefilter($img, IMG_FILTER_NEGATE)){
//imagepng($img, $path);
if($layer > 0)
imagepng($img, $path2);
else
imagejpeg($img,$path);
imagedestroy($img);
return $img;
}
}
我使用上面的代码,加载 layer_0.png(例如)并在其上使用图像过滤器。使用其他所有浏览器都会创建具有效果的图像,但不是在 IE 中!
怎么了??
【问题讨论】:
-
尝试将生成的 PNG 保存在 firefox/chrome 中,然后直接在 IE 中加载该图像。可能是您的图片损坏/不兼容,只有部分浏览器能够打开它。
-
为什么最后返回
$img?那时这是一个无效的 GD 句柄,因为您事先已对其进行了imagedestroy()处理 -
什么版本的IE?如果小于 7,则不支持 alpha 透明 PNG 的
标签: php image internet-explorer