How to Read Image Metadata Using Apache Tika
Many image formats include metadata about the Image. JDeli provides an Apache Tika plugin to extract image metadata.
Note: you will need Apache Tika on your classpath to use this feature. You can download Tika here.
Currently, we support the following formats:
- BMP
- GIF
- HEIC/HEIF
- JPEG/JPG
- JPX/JP2
- JXL
- PNG
- TIFF/TIF
- WEBP
Example Usage
try (final TikaInputStream tik = TikaInputStream.get(Paths.get(file))) {
final MetadataParser parser = new MetadataParser();
final ToXMLContentHandler xmlH = new ToXMLContentHandler();
// Ability to set a password if necessary
final Metadata metadata = new Metadata();
// metadata.set(PDFParser.PASSWORD, "password");
// parseContext is not required so can be null
parser.parse(tik, xmlH, metadata, null);
} catch (final IOException | SAXException | TikaException e) {
e.printStackTrace();
}