Beispiel #1
0
 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;
   }
 }
Beispiel #2
0
 @Override
 public boolean accept(File file, String fileName) {
   return StringHelper.isImage(fileName);
 }