public static BufferedImage getImage(File imageFile) {   
       BufferedImage al = null;   
       try {   
           String imageFileName = imageFile.getName();   
           String imageFormat = imageFileName.substring(imageFileName.lastIndexOf('.') + 1);   
           Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(imageFormat);   
           ImageReader reader = readers.next();   
    
           if (reader == null) {   
              JOptionPane.showConfirmDialog(null,   
                     "Need to install JAI Image I/O package./nhttps://jai-imageio.dev.java.net");   
              return null;   
           }   
    
           ImageInputStream iis = ImageIO.createImageInputStream(imageFile);   
           reader.setInput(iis);   
    
           al = reader.read(0);   
    
           reader.dispose();   
       } catch (IOException ioe) {   
           System.err.println(ioe.getMessage());   
       } catch (Exception e) {   
           System.err.println(e.getMessage());   
       }   
    
       return al;   
    }