62,614
社区成员
发帖
与我相关
我的任务
分享
//本类的功能为获取图片的长和宽
public class ReadImgKnowWandH {
public static void main(String[] args) throws Exception {
new ReadImgKnowWandH().Read("d:\\2.jpg");
}
public void Read(String path) throws Exception{
long lo=System.currentTimeMillis();
ImageIO io = null;
//Image img = io.read(new File(path));
BufferedImage bufImg = io.read(new File(path));
int wi = bufImg.getWidth();
int he = bufImg.getHeight();
System.out.println("宽为:"+wi+",长为:"+he);
System.out.println("时间为:"+Long.toString(System.currentTimeMillis()-lo));
}
}
结果:
宽为:5616,长为:3744
时间为:611