1. 程式人生 > >通過Java獲取圖片的信息

通過Java獲取圖片的信息

edi 取圖 out print ring str public ioe ack

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. 輸出結果如下:

技術分享

通過Java獲取圖片的信息