获取长宽的方法:
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);