Reading EXIF and IPTC with Mistral
While you may have seen me blogging and posting stories about my main projects, I've realized that some of the smaller subprojects didn't receive much attention from me in the last year. For instance Mistral, which is a meta-framework for imaging. "Meta-framework" means that it doesn't provide its own imaging code, but just abstracts some common libraries, such as Java2D or JAI (and others could be plugged in).
One of the benefits of Mistral is its simplified APIs. For instance, it's well known that often extracting metadata from images in Java is a pain in the ass. With Mistral is as easy as:
EditableImage image = EditableImage.create(new ReadOp(new File(...)));
IPTC iptc = image.getMetadata(IPTC.class);
EXIF exif = image.getMetadata(EXIF.class);
Rational shutterSpeed = getShutterSpeedValue();
Every EXIF and most of IPTC properties are accessible with standard getter methods. Furthermore, IPTC and EXIF are fully equipped JavaBeans with bound properties (i.e. PropertyChangeEvent support), which means easy integration with Swing applications. Of course, if you prefer you can even use numeric indexes of tags as in:
EXIF exif = ...
Integer value = exif.getObject(256, Integer.class);
Mistral received just a few changes recently since at the moment it's fine for my needs. But I've received some posts from people using it (and even a couple of code contributions), so - time allowing - I'll fix a couple of remaining things to productize it (at the moment you have to get the latest version by checking out sources from mistral.dev.java.net).