获取长宽的方法:
1.网络图片
try {
BufferedImage image= ImageIO.read(new URL(imgeUrl).openStream());
int width = image.getWidth();// 图⽚宽度
int height = image.getHeight();// 图⽚⾼度
System.out.println("width=" + width);
System.out.println("height=" + height);
} catch (IOException e) {
e.printStackTrace();
}
2.本地图片
File imageFile= new File("D:\\111111.png"); // 图⽚⽂件路径
BufferedImage image = null;
try {
image = ImageIO.read(imageFile);
} catch (IOException e) {
e.printStackTrace();
}
int width = image.getWidth();// 图⽚宽度
int height = image.getHeight();// 图⽚⾼度
System.out.println("width=" + width);
System.out.println("height=" + height);
版权声明:本文为weixin_42235875原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。