閱讀453 返回首頁    go 阿裏雲 go 技術社區[雲棲]


JAVA獲取圖片大小和尺寸

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("C:/Users/Administrator/Pictures/我的圖片/neusoft.png");
  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());
 }
}

原帖地址:https://blog.csdn.net/huangyunzeng2008/article/details/8505640

最後更新:2017-04-04 07:36:09

  上一篇:go Tomcat中兩個不同項目共享Session
  下一篇:go C# Oracle、Sql Server連接(增、刪、改、查)