Java BufferedImage Read isImage(File imageFile)

Here you can find the source of isImage(File imageFile)

Description

is Image

License

Open Source License

Declaration

public static boolean isImage(File imageFile) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;

public class Main {

    public static boolean isImage(File imageFile) {
        if (!imageFile.exists()) {
            return false;
        }// w w w. ja  v  a 2  s.co  m
        try {
            Image img = ImageIO.read(imageFile);
            if (img == null || img.getWidth(null) <= 0
                    || img.getHeight(null) <= 0) {
                return false;
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related

  1. isImage(File file)
  2. isImage(File file)