Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Extract metadata using ImageIO in java

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 357
    Comment on it

    Hello guys

    We are creating a file which have some information about file i.e create date, modify date, tags and description etc. called metadata of the file.

    Now, We are extract the Imagedata using javax.imageIO package requires ImageInputStreams and Readers, for better understanding see below example

    ImageInputStream iis = ImageIO.createImageInputStream(
     new BufferedInputStream(
      new FileInputStream(file)));
    Iterator readers =
     ImageIO.getImageReadersByMIMEType("image/jpeg");
    IIOImage image = null;
    if (readers.hasNext()) {
     ImageReader reader = readers.next();
     reader.setInput(iis, true);
     try {
      image = reader.readAll(0, null);
     } catch (javax.imageio.IIOException iioex) {...}
    
     IIOMetadata metadata = image.getMetadata();
     String[] names = metadata.getMetadataFormatNames();
     for (int i = 0; i < length; i++) {
      if (log.isDebugEnabled()) {
       log.debug("Format name: " + names[ i]);
       log.debug(displayMetadata(metadata.getAsTree(names[i])));
      }
     }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: