关于javax.imageio.IIOException: Invalid icc profile: bad sequence number
2014-04-23 17:09
991 查看
今天碰到项目有客户出现这个错误, 测试网也有, 但是有时候就没有, 很奇怪的问题。 查下了是JDK 的一个BUG。
BUG 地址: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6404011
大概意思是读取图片流的时候, 如果图片本身格式有问题, 他就会报 Invalid icc profile 错误。官网说是1.6已经修复了, 但是我已经是1.6 版本了, 没搞明白怎么回事。
然后找到一篇帖子说重写image可以解决。 参考地址:http://feicer.iteye.com/blog/803138#bc2345723
类似
File doc = new File(file);
FileInputStream inFile = new FileInputStream(doc);
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(inFile);
BufferedImage image = decoder.decodeAsBufferedImage();
FileOutputStream outFile = new FileOutputStream(doc);
ImageIO.write(image, ‘JPEG’, outFile);
inFile.close();
outFile.close();
BufferedImage srcImage = ImageIO.read(doc);
// do Something (例如缩小图片)
BUG 地址: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6404011
大概意思是读取图片流的时候, 如果图片本身格式有问题, 他就会报 Invalid icc profile 错误。官网说是1.6已经修复了, 但是我已经是1.6 版本了, 没搞明白怎么回事。
然后找到一篇帖子说重写image可以解决。 参考地址:http://feicer.iteye.com/blog/803138#bc2345723
类似
File doc = new File(file);
FileInputStream inFile = new FileInputStream(doc);
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(inFile);
BufferedImage image = decoder.decodeAsBufferedImage();
FileOutputStream outFile = new FileOutputStream(doc);
ImageIO.write(image, ‘JPEG’, outFile);
inFile.close();
outFile.close();
BufferedImage srcImage = ImageIO.read(doc);
// do Something (例如缩小图片)
相关文章推荐
- javax.imageio.IIOException: Invalid icc profile: bad sequence number
- ImageIO.read报错:javax.imageio.IIOException: Invalid icc profile: bad sequence number
- javax.imageio.IIOException: Can't create output stream解决方法
- javax.imageio.IIOException: Can't create output stream! (生成验证码Servlet)
- javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Can't create output stream解决方法
- 解决tomcat报错javax.imageio.IIOException: Can't create output stream!
- 图片处理 javax.imageio.IIOException: Unsupported Image Type
- Invalid icc profile: duplicate sequence numbers
- javax.imageio.IIOException: Not a JPEG file: starts with 0x89 0x50
- 使用javax.imageio.ImageIO生成验证码时报错javax.imageio.IIOException: Can't create output stream!
- javax.imageio.IIOException: Not a JPEG file: starts with 0x47 0x49
- 路径名导致的异常:javax.imageio.IIOException: Can't read input file!
- javax.imageio.IIOException: Can't create output stream! (生成验证码Servlet)
- javax.imageio.IIOException: Can't create cache file!
- javax.imageio.IIOException: Can't create output stream! (生成验证码Servlet)
- Invalid icc profile: duplicate sequence numbers
- javax.imageio.IIOException: Can't create output stream! (生成验证码Servlet)
- javax.imageio.IIOException: Can't read input file!