public static IIOMetadata getImageMetadata(File image) throws IOException { Iterator readers = ImageIO.getImageReadersBySuffix(StringHelper.getFileExtension(image.getName())); if (StringHelper.isImage(image.getName())) { if (!readers.hasNext()) { return null; } else { ImageReader imageReader = (ImageReader) readers.next(); FileImageInputStream in = new FileImageInputStream(image); try { imageReader.setInput(in); return imageReader.getImageMetadata(0); } finally { if (in != null) { try { in.close(); } catch (Exception e) { e.printStackTrace(); } } } } } else { return null; } }
@Override public boolean accept(File file, String fileName) { return StringHelper.isImage(fileName); }