context.externalValue(SerializationUtils.arrayToString(hashVals));
hashMapper.parse(context);
}
}
} catch (Exception e) {
throw new ElasticsearchImageProcessException("Failed to index feature " + featureEnum.name(), e);
}
}
// process metadata if required
if (!metadataMappers.isEmpty()) {
try {
Metadata metadata = ImageMetadataReader.readMetadata(new BufferedInputStream(new BytesStreamInput(content, false)), false);
for (Directory directory : metadata.getDirectories()) {
for (Tag tag : directory.getTags()) {
String metadataName = tag.getDirectoryName().toLowerCase().replaceAll("\\s+", "_") + "." +
tag.getTagName().toLowerCase().replaceAll("\\s+", "_");
if (metadataMappers.containsKey(metadataName)) {
Mapper mapper = metadataMappers.get(metadataName);
context.externalValue(tag.getDescription());
mapper.parse(context);
}
}
}
} catch (ImageProcessingException e) {
logger.error("Failed to extract metadata from image", e);
if (!ignoreMetadataError) {
throw new ElasticsearchImageProcessException("Failed to extract metadata from image", e);
}
}
}