Java ImageIO:我可以将 PNG-24 文件转换为 PNG-8 吗?
场景是这样的: 该网络应用程序的用户可以通过选择自己的徽标图像、背景颜色和背景图像来自定义网站。
问题是IE6不支持透明PNG。我尝试过几种客户端解决方案,但都在某一方面存在缺陷(大多数不支持 css 属性 background-repeat
)。
我正在寻找在服务器上创建两个独立图像的替代解决方案,一个用于现代的、透明 png 兼容的浏览器,另一个用于 IE6。
问题是,我可以使用 ImageIO 来完成此任务吗?基本上,我会检测图像是否为 PNG-24 格式并将其转换为 PNG-8(IE6 支持)。
The scenario is this:
Users of the webapp can customize the website by choosing their own logo image, background colors and background images.
Problem is that IE6 does not support transparent PNG. I've tried several client-side solutions, but all fall short on one aspect or the other (most don't support the css property background-repeat
).
I'm looking for the alternate solution of creating two separate images on the server, one for modern, transparent-png-compliant browsers and one for IE6.
Question is, can I accomplish this with ImageIO
? Basically, I would detect whether the image is in PNG-24 format and convert it to PNG-8 (which is supported on IE6).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您需要 IE6 中的透明度,请考虑仅为该浏览器提供 GIF。这可行吗?
If you need transparency in IE6, then consider simply shipping a GIF instead for that browser. Would that be feasible?
我知道你说过你使用了各种客户端解决方案,但是这个解决方案在我正在使用的项目中工作,所以以防万一: http://jquery.andreaseberhard.de/pngFix/
(如果您已经尝试过,请随时发表评论,我将删除答案)
I know you said you used various client-side solutions, but this one worked in the project I was using, so just in case : http://jquery.andreaseberhard.de/pngFix/
(if you already tried it, feel free to comment, I'll delete the answer)