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);
java获取图片原始尺寸的相关教程结束。