Link
Skip to main content

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();
}

Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL (AVIF soon) that are not supported in Java.
  • Process images up to 3x faster than ImageIO and alternative Java image libraries.
  • Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  • Handle JPEG, PNG, TIFF image file formats fully in Java.
  • Keep your Image files secure as JDeli makes no calls to any external system or third party library.

Start Your Free Trial