How do I discover the size of an image file (GIF or JPEG) on disk?

Alex Chaffee

First, load the image. If you have Swing, you can use

    ImageIcon icon = new ImageIcon(args[0]);
    Image image = icon.getImage();
If you do not have Swing, you will need access to a toolkit, a component, and a media tracker. See "How do I make sure an Image is loaded before I try to display it?"http://www.jguru.com/jguru/faq/view.jsp?EID=20617

Once you have loaded the image, you can use its getHeight() and getWidth() methods, which work as expected.