I'm using this code to get these three diferent metadata attributes ('Object Name', 'ImageDescription' and 'Keywords') using the apache commons.imaging (snapshot). However, I have no clue about how to write into this attributes. Does anybody know the proper way? Thanks in advance...
IImageMetadata metadata = null;
String name;
try {
metadata = Imaging.getMetadata(new File(filename));
} catch (ImageReadException | IOException e) {
}
if (metadata instanceof JpegImageMetadata) {
final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
final List<IImageMetadataItem> items = jpegMetadata.getItems();
for (int i = 0; i < items.size(); i++) {
final IImageMetadataItem item = items.get(i);
name = item.toString().substring(0, item.toString().indexOf(":"));
switch (name) {
case "Object Name" :
case "ImageDescription" :
case "Keywords" :
System.out.println(item.toString());
break;
}
}
}