Creating a BufferedImage from .tiff file
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 c开发者_开发百科ore.Page.initGuesses(Page.java:101)
....
Does anyone know what could be the problem? Am I doing something incorrectly?
Thanks!
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:
Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"
This solution worked for me.
精彩评论