Following method can be used to get width and height of jpg, gif, or png file
import javax.swing.ImageIcon;
public void printSize(){
ImageIcon jpegImage = new
ImageIcon("C:\\Users\\prageethj\\Desktop\\cute.jpg");
int height = jpegImage.getIconHeight();
int width = jpegImage.getIconWidth();
System.out.println(width + "x" + height);
}
public void printSize(){
ImageIcon jpegImage = new
ImageIcon("C:\\Users\\prageethj\\Desktop\\cute.jpg");
int height = jpegImage.getIconHeight();
int width = jpegImage.getIconWidth();
System.out.println(width + "x" + height);
}
Read full article from Java Developers Path: How to get width and height of an image in Java
No comments:
Post a Comment