首页 > 代码库 > java 获取图片大小(尺寸)

java 获取图片大小(尺寸)

1,获取本地图片大小(尺寸)

File picture=new File(strSrc);
BufferedImage sourceImg=ImageIO.read(new FileInputStream(picture));

sourceImg.getWidth();

sourceImg.getHeight();

2,获取网络图片大小(尺寸)

BufferedImage sourceImg=ImageIO.read(new URL(strSrc).openStream());

sourceImg.getWidth();

sourceImg.getHeight();

-------------------------------------------------