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);    

 

相关文章:

  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2021-11-08
猜你喜欢
  • 2022-12-23
  • 2021-08-01
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案