Quantcast
Channel: IT社区推荐资讯 - ITIndex.net
Viewing all articles
Browse latest Browse all 11810

图片处理 javax.imageio.IIOException: Unsupported Image Type

$
0
0

用ImageIO处理图片:

 

Java代码   收藏代码
  1. ImagetIO img = ImageIO.read(new File(InputDir + InputFileName));  

JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new FileInputStream( new File("e://1.jpg") ) );
BufferedImage sourceImg = decoder.decodeAsBufferedImage();

 报异常:

 

Caused by: javax.imageio.IIOException: Unsupported Image Type

产生原因:

ps或其他软件处理过的图片保存为jpg格式时,默认的模式是CMYK模式(这是给印刷机用的)。在图像-->模式中改为RGB模式才是显示器用的。

 

http://zhangmingji.iteye.com/blog/1969693

解决办法:方法一:通知用户修改图片格式为RGB。

方法二:用代码在后台转换。

http://iaiai.iteye.com/blog/1461370

 

参考: http://blog.sina.com.cn/s/blog_600ff075010153wn.html

          http://iaiai.iteye.com/blog/1461370

 

附件为错误测试图片。

 

http://www.cnblogs.com/yjhrem/articles/3503060.html

http://zhangmingji.iteye.com/blog/1969693



已有 0人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐




Viewing all articles
Browse latest Browse all 11810

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>