java判断上次图片的尺寸，将得到的文件对象转成流，使用ImageIO读取获取宽高属性BufferedImage curImg = ImageIO.read(file.getInputStream()); int picWidth = curImg.getWidth();//获取宽 int picHeight = curImg.getHeight();//获取高 int standWidth = Integer.parseInt(width); int standHeight = Integer.parseInt(height); //给客户预留一些误差 if(Math.abs(standWidth-picWidth) >5 || Math.abs(standHeight-picHeight) >5){ result.setCode(-2); return result; }