Here you can find the source of isImage(File img)
public static boolean isImage(File img)
//package com.java2s; //License from project: Apache License import java.awt.Image; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class Main { public static boolean isImage(File img) { try {//from w w w . ja v a 2 s . c o m return isImage(ImageIO.read(img)); } catch (IOException e) { return false; } } public static boolean isImage(Image img) { return img != null && img.getWidth(null) > -1 && img.getHeight(null) > -1; } }