Friday, January 19, 2007

File Type Metadata Discovery, Part 2: Images

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.

Java ImageIO

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.

There is also a jai-imageio project on which is a set of ImageReader and ImageWriter plugins for the ImageIO API, primarily built by the JAI team (see this thread at

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().


I have created a simple library that gathers all available image metadata into a Map set. Download ImageMetadataDiscoverer at Sourceforge or read the javadocs.

Need More?

More specific needs can be met by the wide variety of image tools available for Java. Marco Schmidt has a nice list of raster and vector libraries. DMOZ also maintains a directory of libraries.

No comments: