我正在尝试从 URL 在线获取图像的尺寸,就像这个问题中的人一样:
Java/ImageIO getting image dimensions without reading the entire file?
但是,我不太知道如何使用那里的最佳答案的代码来获得结果。我想获取图像的高度和宽度,而无需加载它。
如果我有一个指向图像的 URL,我该如何放置 resourceFile?
最佳答案
参见ImageIO.createImageInputStream(Object)
?
Parameters:
input
- anObject
to be used as an input source, such as aFile
, readableRandomAccessFile
, orInputStream.
此外,正如@Hover 评论:
..you would need the
InputStream
from theURL
for this.
关于java - 如何正确使用此图像代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10593189/