图片压缩时 某个 jpeg图片 报错 Unsupported Image Type

ImageIO.read 读取某个图片的时候报错  Unsupported Image Type。

其他的同类型图片没问题。查询发现是这样的:默认的模式是CMYK模式(注意,这是给印刷机用的)。在图像-->模式中改为RGB模式才是显示器用的

对应的网站:http://stackoverflow.com/questions/2408613/unable-to-read-jpeg-image-using-imageio-readfile-file 


最好的解决方案如下,采用 twelvemonkeys 的相关组件。代码不用任何修改


使用方法。

maven中加上对应的dependency,

web.xml中加上   

 <listener>
        <display-name>ImageIO service provider loader/unloader</display-name>
        <listener-class>com.twelvemonkeys.servlet.image.IIOProviderContextListener</listener-class>
    </listener>

Old post, but for future reference:

Inspired by this question and links found here, I've written a JPEGImageReader plugin for ImageIO that supports CMYK color models (both with original color model, or implicitly converted to RGB on read). The reader also does proper color conversion, using the ICC profile embedded in the JPEG stream, in contrast to other solutions mentioned here.

It's plain Java and does not require JAI. The source code and binary distributions is freely available atgithub.com/haraldk/TwelveMonkeys.

Once you have it installed, it allows you to read CMYK JPEGs using ImageIO.read(...) like this:

File cmykJPEGFile = new File(/*path*/);
BufferedImage image = ImageIO.read(cmykJPEGFile);

I.e.: In most cases, it's not necessary to modify your code.



参考其他网站:http://blog.csdn.net/shixing_11/article/details/6897871

http://www.doc88.com/p-58261301281.html


http://www.oschina.net/p/evathumber/similar_projects?lang=19&sort=time&p=1

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值