I am using commons io imaging library to add xmp metadata to a JPEG file. This is how I'm doing it:
String xmpXml = "<dc:decription>some sample desc123</dc:description>";
JpegXmpRewriter rewriter = new JpegXmpRewriter();
rewriter.updateXmpXml(is,os, xmpXml);
Running exiftool
on the above file shows the created xmp data from above:
$ exiftool 167_sample.jpg | grep "Description"
Description : some sample desc123
However, using metadata-extractor I can't read the Description
tag from above:
Metadata metadata = com.drew.imaging.ImageMetadataReader.readMetadata(file.inputStream)
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) {
XMPMeta xmpMeta = xmpDirectory.getXMPMeta();
XMPIterator itr = xmpMeta.iterator();
while (itr.hasNext()) {
XMPPropertyInfo property = (XMPPropertyInfo) itr.next();
System.out.println(property.getPath() + ": " + property.getValue());
}
}
More interestingly, metadata-extractor
CAN read the Description
tag when exiftool
is used to create the xmp tag
$ exiftool -xmp-dc:description=Manuallyaddedthis 167_sample.jpg
Metadata metadata = com.drew.imaging.ImageMetadataReader.readMetadata(new File ("167_sample.jpg"))
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) {
XMPMeta xmpMeta = xmpDirectory.getXMPMeta();
XMPIterator itr = xmpMeta.iterator();
while (itr.hasNext()) {
XMPPropertyInfo property = (XMPPropertyInfo) itr.next();
System.out.println(property.getPath() + ": " + property.getValue());
}
}