获取图片尺寸

package test;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.imageio.ImageIO;

public class CalPit {
	  public static void main(String[] args) throws FileNotFoundException, IOException {  
	        File picture = new File("E:\\图片\\1.jpg");  
	        BufferedImage sourceImg =ImageIO.read(new FileInputStream(picture));   
	        System.out.println(String.format("%.1f",picture.length()/1024.0));  
	        System.out.println(sourceImg.getWidth());  
	        System.out.println(sourceImg.getHeight());  
	    }

}

  

posted @ 2015-01-19 11:29  a757956132  阅读(251)  评论(0编辑  收藏  举报