BufferedImage image1 = ImageIO.read(new File("照片路径")); int width = image1.getWidth(); int height = image1.getHeight(); 将目标文件的路径填进去就好了。