您的位置:首页 > 编程语言 > Java开发

java获取图片原始尺寸

2017-01-05 17:18 330 查看
java获取图片原始尺寸

URL url = null;
InputStream is = null;
BufferedImage img = null;

try {
url = new URL(picurl);
is = url.openStream();
img = ImageIO.read(is);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {

try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}

//System.out.println(img.getHeight()+"/"+img.getWidth());

String str = "{\"width\":\""+img.getWidth()+"\",\"height\":\""+img.getHeight()+"\"}";
out.print(str);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: