---
title: "获取图片的宽度和高度"
author: "thoughtfly"
date: "2009-10-28T12:34:55Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2011-05-25T17:13:48Z"
id: 505562
url: "https://thoughtfly.iteye.com/blog/505562"
---

java.io.File file = new java.io.File(&quot;./aa.jpg&quot;));
java.awt.image.BufferedImage bi = javax.imageio.ImageIO.read(file);
bi.getWidth(); //获得 宽度
bi.getHeight() ;//获得 高度

或者：

new ImageIcon(img).getImage().getHeight(observer)