从 .tiff 文件创建 BufferedImage
我正在尝试从 .tiff 文件创建 BufferedImage(raw() 是 .tiff 图像的路径):
// read a buffered image from the disk
BufferedImage buff = ImageIO.read(new File(raw()));
最初 ImageIO.read 返回 null,但我读到我需要将 JAI ImageIO JAR 添加到您的类路径,我做到了。现在我收到以下错误:
Exception in thread "main" javax.imageio.IIOException: I/O error reading image metadata!
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:340)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:310)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.prepareRead(TIFFImageReader.java:971)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1153)
at javax.imageio.ImageIO.read(ImageIO.java:1422)
at javax.imageio.ImageIO.read(ImageIO.java:1282)
at core.Page.initGuesses(Page.java:101)
....
有谁知道可能是什么问题?我做错了什么吗?
谢谢!
I'm trying to created a BufferedImage from a .tiff file (raw() is the path of a .tiff image):
// read a buffered image from the disk
BufferedImage buff = ImageIO.read(new File(raw()));
Originally ImageIO.read was returning null but I read that I need to add the JAI ImageIO JARs to your classpath, which I did. Now I'm getting the following error:
Exception in thread "main" javax.imageio.IIOException: I/O error reading image metadata!
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.readMetadata(TIFFImageReader.java:340)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:310)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.prepareRead(TIFFImageReader.java:971)
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1153)
at javax.imageio.ImageIO.read(ImageIO.java:1422)
at javax.imageio.ImageIO.read(ImageIO.java:1282)
at core.Page.initGuesses(Page.java:101)
....
Does anyone know what could be the problem? Am I doing something incorrectly?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也面临着同样的问题。我试图从 tiff byte[] 获取 BufferedImage 但结果为 null。
我注释了 Tomcat 的 server.xml 文件中与 JreMemoryLeaks 相关的一行。
只需评论这一行:
这个解决方案对我有用。
I was also facing same problem. I was trying to get BufferedImage from tiff byte[] but was getting null as result.
I have commented one line from Tomcat's server.xml file which is related to JreMemoryLeaks.
Just comment this line:
This solution worked for me.