programming-examples/java/Applets_AWT/Finding Width and Height of an Image.java

19 lines
495 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
Finding Width and Height of an Image
import java.awt.*;
import javax.swing.*;
public class ImageXY
{
public static void main(String[] args)
{
Image image = Toolkit.getDefaultToolkit().getImage("test.jpg");
ImageIcon icon = new ImageIcon(image);
int height = icon.getIconHeight();
int width = icon.getIconWidth();
System.out.println("height"+height);
System.out.println("width"+width);
}
}