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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM