Mega Code Archive

 
Categories / Java / 2D Graphics GUI
 

Get the dimensions of the image; these will be non-negative

import java.awt.Image; import java.awt.Toolkit; public class BasicDraw {   public static void main(String[] args) {     Image image = new ImageIcon("image.gif").getImage();          width = image.getWidth(null);     height = image.getHeight(null);   } }