how to get the size of an image in java

后端 未结 4 1483
谎友^
谎友^ 2021-02-03 11:14

hi I am using Jtidy parser in java.


URL url = new URL(\"http://l1.yimg.com/t/frontpage/baba-ramdev-310511-60.jpg\");  
Image image = new ImageIcon(url).g         


        
4条回答
  •  情话喂你
    2021-02-03 11:51

    This is one of the simplest method to find the dimensions of image.

     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);
    

提交回复
热议问题