JAVA获取图片大小和尺寸

来源:互联网 发布:算法精解 pdf 百度云 编辑:程序博客网 时间:2024/05/21 06:22
package stone;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());}}

原创粉丝点击