通过Java获取图片的信息

1.   图片:96 * 96

 

2. 程序如下:

package com.bnc.bufferedImage;

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

import javax.imageio.ImageIO;

public class TestBufferedImage {
    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedImage image = ImageIO.read(new FileInputStream("D:/1230/logo_img_admin.png"));
        int width = image.getWidth();
        int height = image.getHeight();
        System.out.println("width:"+width);
        System.out.println("height:"+height);
    }
}

3. 输出结果如下:

 

posted @ 2017-09-29 10:25  beibidewomen  阅读(6385)  评论(0编辑  收藏  举报