File Type Metadata Discovery, Part 2: Images
In a previous article, I evaluated various libraries to determine which most accurately identified a file's type. This article represents part two in a series of articles that explore how to discover metadata about a file after its type has been detected.
The primary Java library for image handling is javax.imageio which provides a pluggable architecture for working with images stored in files and accessed across the network and a framework for the addition of format-specific plugins. Plug-ins for several common formats are included with Java Image I/O, but third parties can use this API to create their own plugins to handle special formats.
The javax.imageio has comprehensive metadata capability included in the ImageReader.getStreamMetadata() and ImageReader.getImageMetadata() methods. These methods generate an IIOMetadataFormat object whose values are accessible through a DOM tree. The amount of image specific metadata available is staggering, and probably wouldn't be useful to someone unless they were creating a very image-centric application. However, in a digital asset management system, simple metadata such as height and width are readily available from ImageReader.getImageMetadata().