ie6 - gd 和 php 图像输出
我正在尝试用灰度滤镜显示图像。这是我的代码:
$images = glob('gallery/*small*');
shuffle($images);
array_splice($images, 3);
$imgHandles = array();
$imgBuffered = array();
for( $i = 0; $i < 3; $i++)
{
$imgHandles[$i] = imagecreatefromstring( file_get_contents($images[$i]) );
imagefilter( $imgHandles[$i], IMG_FILTER_GRAYSCALE );
ob_start();
imagepng( $imgHandles[$i] );
$imgBuffered[$i] = ob_get_contents();
ob_end_clean();
imagedestroy( $imgHandles[$i] );
}
输出:
for( $i = 0; $i < 3; $i++ )
{
echo "<a href=\"gallery.php\">
<img class=\"photo\" src='data:image/png;base64,".base64_encode( $imgBuffered[$i] )."' /></a>";
}
在 Opera、ff、chrome、safari 中一切都很好,但 ie6 不显示图像。为什么?
我制作了如下页面的代码: http://dean.edwards.name/博客/2005/06/base64-ie/ 我看到照片,但几秒钟后它们就隐藏起来了……我真的不知道为什么。你能帮我处理这些事情吗?
i'm trying to show image with grayscale-filter. Here is my code:
$images = glob('gallery/*small*');
shuffle($images);
array_splice($images, 3);
$imgHandles = array();
$imgBuffered = array();
for( $i = 0; $i < 3; $i++)
{
$imgHandles[$i] = imagecreatefromstring( file_get_contents($images[$i]) );
imagefilter( $imgHandles[$i], IMG_FILTER_GRAYSCALE );
ob_start();
imagepng( $imgHandles[$i] );
$imgBuffered[$i] = ob_get_contents();
ob_end_clean();
imagedestroy( $imgHandles[$i] );
}
And outputting:
for( $i = 0; $i < 3; $i++ )
{
echo "<a href=\"gallery.php\">
<img class=\"photo\" src='data:image/png;base64,".base64_encode( $imgBuffered[$i] )."' /></a>";
}
In opera, ff, chrome, safari everything is fine, but ie6 doesn't show images. Why?
I made code like at page: http://dean.edwards.name/weblog/2005/06/base64-ie/
I see pictures, but in some seconds they hide... I really don't know why. Can you help me with this stuff?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
数据 URI 方案IE6 不支持(显然也不支持 IE7)。您需要将图像保存在某处,并将保存的图像的 URL 作为
img src
提供,或者您需要通过单独的脚本动态生成它并执行类似的操作>img src="path/to/image_generator.php"
。The data URI scheme isn't supported in IE6 (nor IE7, apparently). You'll need to save the image somewhere and provide the URL to the saved image as the
img src
, or you'll need to generate it on the fly via a separate script and do something likeimg src="path/to/image_generator.php"
.ceejayoz 的方法可能是最好的,他/她说 IE6 不支持该方案是正确的。 这里有一个关于如何在 IE 中执行此操作的页面,但是我希望您有充分的理由不使用
/path/to/image_generator.php
版本。为此,您可以创建一个仅执行
imagepng
操作的脚本,然后发送标头,向浏览器指示相关图像是 png。例如,img_generate.php
:然后在你的html中
ceejayoz's approach is probably best, and he\she is correct in saying that the scheme isn't supported in IE6. Here is a page about how to do it in IE, but I hope you have a good reason for not doing the
/path/to/image_generator.php
version.To do that, you would create a script that just does
imagepng
, for example, and then sends headers indicating to the browser that the image in question is a png. e.g.,img_generate.php
:and then in your html