Getting Height and Width of Image in Java without an ImageObserver

后端 未结 3 1828
无人共我
无人共我 2021-01-19 09:36

I am trying to get the height and width of images (via a url) in Java without an ImageObserver. My current code is:

public static v         


        
3条回答
  •  渐次进展
    2021-01-19 10:14

    Following should work

       Image image = Toolkit.getDefaultToolkit().getImage(image_url);
       ImageIcon icon = new ImageIcon(image);
       int height = icon.getIconHeight();
       int width = icon.getIconWidth();
       sb.append(line + ","+ height + "," + width + newline);
    

提交回复
热议问题