http://cs-man.iteye.com/blog/652918

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

import java.awt.image.BufferedImage;
  
import java.io.File;
  
import java.io.IOException;
  
import javax.imageio.ImageIO;

public class Test {

public static void main(String[] args) {
  
File picFile = new File("D:\\1.gif"); // 图片文件路径
  
BufferedImage image = null;
  
try {
  
image = ImageIO.read(picFile);
  
} catch (IOException e) {
  
e.printStackTrace();
  
}
  
int width = image.getWidth();// 图片宽度
  
int height = image.getHeight();// 图片高度
  
System.out.println("width=" + width);
  
System.out.println("height=" + height);
  
}

}