• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I store metadata in an image file?  RSS feed

 
Robert Eugene
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a system that reads in XML files and processes the data. The core part of this system is nearly complete. I now have a requirement that allows users to submit image documents (e.g. jpg, jpeg, pdf, png, tif, and tiff) into a particular folder location. At a high level, when these files arrive, my process routes these files to another folder based on the filename. This works well enough for the more simple case, but I don't think it scales very well when you consider there may be more destination folders with more complex rules that determine the proper routing. I would like to take an approach based on reading metadata inside the files -- I understand that some files may have a file header section that is separate from the actual data.

This seems like it would be straightforward with However, I think that was introduced with the NIO in Java 7. Right now, I have a requirement to run on servers that are running Java 6. My first preference would be to find a way to code this in Java without too much effort and without relying on a third party solution. Any ideas?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt that the NIO class you mention can be used to read metadata from image files.

How and what metadata is stored in files depends on the file format.

The ImageIO API (the package javax.imageio) has classes and methods to read and write metadata from different image file formats. For example class ImageReader has different getImageMetadata methods. You'll have to study that API to find out how to read metadata from image files. See also the package javax.imageio.metadata.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!