I am looking to extract the camera related information from a jpg using Java. I have looked around but have not been able to find a solution to my problem. I am exporting my photos from Aperture on my mac (OS X 10.7) and want to use the data from Aperture that is available in the file info.
Any ideas?
I am looking to have Dimensions and Key Words extracted from photos like this one: 80.167.88.49/masters/test.html. Currently i get an exception when trying to use the Metadata Extractor. I don't know if Aperture is adding information that cannot be handled but it throws an exception on all photos from Aperture.
Exception in thread "main" java.lang.NoClassDefFoundError: com/adobe/xmp/XMPException
at com.drew.imaging.jpeg.JpegMetadataReader.extractMetadataFromJpegSegmentReader(Unknown Source)
at com.drew.imaging.jpeg.JpegMetadataReader.readMetadata(Unknown Source)
at com.drew.imaging.ImageMetadataReader.readMetadata(Unknown Source)
at com.drew.imaging.ImageMetadataReader.readMetadata(Unknown Source)
at ImageScaler.main(ImageScaler.java:141)
Caused by: java.lang.ClassNotFoundException: com.adobe.xmp.XMPException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 5 more
Code:
public static void main (String[] args){
File image = new File("/Users/peterla/Desktop/P8214462.jpg");
Metadata metadata = null;
try {
metadata = ImageMetadataReader.readMetadata(image);
} catch (ImageProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Directory directory;
// Keywords
directory = metadata.getDirectory(IptcDirectory.class);
String keywords[] = directory.getStringArray(IptcDirectory.TAG_KEYWORDS);
// Dimensions
directory = metadata.getDirectory(JpegDirectory.class);
String height = directory.getString(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
String width = directory.getString(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
}