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);
System.err.println(iptc.getSubject());
EXIF exif = image.getMetadata(EXIF.class);
Rational shutterSpeed = getShutterSpeedValue();
System.err.println(shutterSpeed.doubleValue());
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).
| Attachment | Size |
|---|---|
| 1343_Overview.png | 45.36 KB |
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
Jonathan Giles replied on Sat, 2009/02/07 - 6:42pm
Fabrizio Giudici replied on Sun, 2009/02/08 - 6:18pm
Jonathan Giles replied on Sun, 2009/02/08 - 10:33pm
in response to:
Fabrizio Giudici
Interesting.
Do you have any plans to implement this functionality in the coming weeks or months? Right now I am working on a program that reads and writes IPTC data, and am likely having to buy a commercial license for proprietary Java software (Imagero) to do this. This API is dated and not particularly pleasurable to work with.
If there is any way I can help, let me know and I'll see what I can do. Probably best you email me directly rather than go through this chat board (jo at jogiles.co.nz)
Cheers,
Jonathan
Fabrizio Giudici replied on Wed, 2009/03/04 - 7:47am