你好
我在java中使用Jtidy解析器。
URL url = new URL("http://l1.yimg.com/t/frontpage/baba-ramdev-310511-60.jpg");
Image image = new ImageIcon(url).getImage();
int imgWidth = image.getWidth(null);
int imgHeight = image.getHeight(null);
上面的代码工作正常,我正确获取高度和宽度。但是我想查看图像的大小(例如是否以 KB 为单位,或以 MB 为单位)。请帮助我,如何获取图像的大小.有什么方法吗。
这是查找图像尺寸的最简单方法之一。
URL url=new URL("Any web image url");
BufferedImage image = ImageIO.read(url);
int height = image.getHeight();
int width = image.getWidth();
System.out.println("Height : "+ height);
System.out.println("Width : "+ width);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)