简体   繁体   English

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

[英]Java ImageIO: Can I convert a PNG-24 file to PNG-8?

The scenario is this: Users of the webapp can customize the website by choosing their own logo image, background colors and background images. 场景是这样的:webapp的用户可以通过选择他们自己的徽标图像,背景颜色和背景图像来自定义网站。

Problem is that IE6 does not support transparent PNG. 问题是IE6不支持透明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 ). 我已经尝试了几种客户端解决方案,但是在一方面或另一方面都不尽如人意(大多数都不支持css属性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. 我正在寻找在服务器上创建两个单独图像的替代解决方案,一个用于现代,透明-png兼容的浏览器,另一个用于IE6。

Question is, can I accomplish this with ImageIO ? 问题是,我可以用ImageIO来完成吗? Basically, I would detect whether the image is in PNG-24 format and convert it to PNG-8 (which is supported on IE6). 基本上,我会检测图像是否是PNG-24格式并将其转换为PNG-8(IE6支持)。

If you need transparency in IE6, then consider simply shipping a GIF instead for that browser. 如果你在IE6中需要透明度,那么考虑只为该浏览器发送GIF。 Would that be feasible? 那可行吗?

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

(if you already tried it, feel free to comment, I'll delete the answer) (如果您已经尝试过,请随意发表评论,我会删除答案)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM