本地磁盘文件
File file = new File("C:\\Users\\root\\Desktop\\test.jpg");
BufferedImage bufferedImage = ImageIO.read(new FileInputStream(file));
int height = bufferedImage.getHeight();
int width = bufferedImage.getWidth();
long size = file.length() / 1024;
System.out.println(height);
System.out.println(width);
System.out.println(size);
Spring中通过表单提交的文件
MultipartFile multipartFile = [your multipartfile];
BufferedImage bufferedImage = ImageIO.read(multipartFile.getInputStream());
int height = bufferedImage.getHeight();
int width = bufferedImage.getWidth();
long size = file.getSize() / 1024;
System.out.println(height);
System.out.println(width);
System.out.println(size);```