Java ImageIO:我可以将 PNG-24 文件转换为 PNG-8 吗?

发布于 2024-08-18 00:05:25 字数 297 浏览 7 评论 0原文

场景是这样的: 该网络应用程序的用户可以通过选择自己的徽标图像、背景颜色和背景图像来自定义网站。

问题是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不喜欢何必死缠烂打 2024-08-25 00:05:25

如果您需要 IE6 中的透明度,请考虑仅为该浏览器提供 GIF。这可行吗?

If you need transparency in IE6, then consider simply shipping a GIF instead for that browser. Would that be feasible?

回忆追雨的时光 2024-08-25 00:05:25

我知道你说过你使用了各种客户端解决方案,但是这个解决方案在我正在使用的项目中工作,所以以防万一: 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文