使用Java读取图像:无效的icc配置文件:无效的icc标记数
我正在阅读来自不同网址的图片。其中一些成为了一个非常有趣的问题 完整错误:使用Java读取图像:无效的icc配置文件:无效的icc标记数,java,inputstream,urlconnection,color-profile,color-management,Java,Inputstream,Urlconnection,Color Profile,Color Management,我正在阅读来自不同网址的图片。其中一些成为了一个非常有趣的问题 完整错误:javax.imageio.IIOException:无效的icc配置文件:无效的icc标记数 一些代码,但我相信它不会有多大帮助: URLConnection wat = new URL(strurl).openConnection(); wat.setRequestProperty("User-Agent", userAgent); InputSt
javax.imageio.IIOException:无效的icc配置文件:无效的icc标记数
一些代码,但我相信它不会有多大帮助:
URLConnection wat = new URL(strurl).openConnection();
wat.setRequestProperty("User-Agent", userAgent);
InputStream in = null;
try {
in = wat.getInputStream();
} catch(FileNotFoundException e) {
e.printStackTrace();
Logger.getLogger().logException(e);
}
if(in == null) continue;
ByteArrayOutputStream outArray = new ByteArrayOutputStream();
byte[] bytes = new byte[50000];
int bytesRead;
while((bytesRead = in.read(bytes, 0, bytes.length)) > 0) {
outArray.write(bytes, 0, bytesRead);
bytesRead = 0;
}
in.close();
String format = getFileFormat(outArray.toByteArray());
in = new ByteArrayInputStream(outArray.toByteArray());
BufferedImage image = null;
try {
image = ImageIO.read(in);
} catch(IOException e) {
e.printStackTrace();
Logger.getLogger().logException(e);
}
我首先读取字节以确定它是什么文件类型
这是导致引发此异常的照片:
奇怪的是,我找不到关于这个错误的任何信息
编辑:这实际上不是一个解决方案,但因为我正在保存这些文件,所以我停止构建
buffereImage
,只是将这些字节“转储”到一个文件中。类似的问题:这实际上很有帮助。。。我相信这些标准就是问题所在。但用于转换它的库的链接已经失效。