---
title: "JAVA上传图片时获取尺寸"
author: "tomp110"
date: "2009-02-19T12:04:27Z"
tags: []
slug: "java"
draft: false
lastmod: "2009-02-19T12:04:27Z"
id: 335378
url: "https://tomp110.iteye.com/blog/335378"
---

BufferedImage sourceImg = javax.imageio.ImageIO.read(is);
得到BufferedImage对象，其中的is是InputStream，用来接收图片数据的流。   
取图像宽：sourceImg.getWidth()   
取图像高：sourceImg.getHeight()