如何将 Java 中的 TIFF 图像读入 BufferedImage?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31554374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I read a TIFF image in Java into a BufferedImage?
提问by user119567
I was having a problem where my image analysis program would crash whenever I used TIFF images. I found that the problem was that BufferedImage img = ImageIO.read(file)
was returning null, even though the file existed. With some extra research, I found that the ImageIO class doesn't support TIFF images by default, but that the Java Advanced Imaging JARS would fix my problem. I was wondering how I could get JAI working under eclipse (for windows) so that I could use my program. I've done some searching, bu there is no clear guide that I can find.
我遇到了一个问题,每当我使用 TIFF 图像时,我的图像分析程序就会崩溃。我发现问题是BufferedImage img = ImageIO.read(file)
返回空值,即使文件存在。通过一些额外的研究,我发现ImageIO 类默认不支持 TIFF 图像,但是 Java Advanced Imaging JARS 可以解决我的问题。我想知道如何让 JAI 在 eclipse 下工作(对于 Windows),以便我可以使用我的程序。我已经做了一些搜索,但是我找不到明确的指南。
Alternatively, if there is a different class/method for reading images into BufferedImage
objects, I could use that. I even have the program detecting the file extension so if it works only for TIFF files that's fine.
或者,如果有不同的类/方法将图像读入BufferedImage
对象,我可以使用它。我什至让程序检测文件扩展名,所以如果它只适用于 TIFF 文件,那很好。