[英]ImageIO.read(FileInputStream) returns null when reading a very large image
I need to read an image, resize it and then save it. 我需要读取图像,调整大小然后保存。 However, when reading a very large image, ImageIO#read()
returns null. 但是,当读取非常大的图像时, ImageIO#read()
返回null。
FileInputStream f = new FileInputStream(imagePath);
image = ImageIO.read(f);
How is this caused and how can I solve it? 这是怎么引起的,我该如何解决?
Image I/O has built-in support for GIF, PNG, JPEG, BMP, and WBMP only. 图像I / O内置对GIF,PNG,JPEG,BMP和WBMP的支持。 Are you trying to load any other type of image than these. 您是否要加载除这些以外的任何其他类型的图像。 See Reading/Loading an Image for details. 有关详细信息,请参见读取/加载图像 。
You may check the list of registered readers using ImageIO.getReaderFormatNames()
. 您可以使用ImageIO.getReaderFormatNames()
检查注册阅读器的列表。 For me it lists [BMP, bmp, jpg, JPG, wbmp, jpeg, png, JPEG, PNG, WBMP, GIF, gif]
对我来说,它列出了[BMP, bmp, jpg, JPG, wbmp, jpeg, png, JPEG, PNG, WBMP, GIF, gif]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.