Class ImageMetadataExtractor

java.lang.Object
org.apache.tika.parser.image.ImageMetadataExtractor

public class ImageMetadataExtractor extends Object
Uses the Metadata Extractor library to read EXIF and IPTC image metadata and map to Tika fields.

As of 2.4.0 the library supports jpeg and tiff. As of 2.8.0 the library supports webp.

  • Constructor Details

    • ImageMetadataExtractor

      public ImageMetadataExtractor(org.apache.tika.metadata.Metadata metadata)
      Parameters:
      metadata - to extract to, using default directory handlers
    • ImageMetadataExtractor

      public ImageMetadataExtractor(org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.image.ImageMetadataExtractor.DirectoryHandler... handlers)
      Parameters:
      metadata - to extract to
      handlers - handlers in order, note that handlers may override values from earlier handlers
  • Method Details

    • parseJpeg

      public void parseJpeg(File file) throws IOException, SAXException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      SAXException
      org.apache.tika.exception.TikaException
    • parseTiff

      public void parseTiff(File file) throws IOException, SAXException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      SAXException
      org.apache.tika.exception.TikaException
    • parseWebP

      public void parseWebP(File file) throws IOException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      org.apache.tika.exception.TikaException
    • parseHeif

      public void parseHeif(InputStream is) throws IOException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      org.apache.tika.exception.TikaException
    • parseRawExif

      public void parseRawExif(InputStream stream, int length, boolean needsExifHeader) throws IOException, SAXException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      SAXException
      org.apache.tika.exception.TikaException
    • parseRawExif

      public void parseRawExif(byte[] exifData) throws IOException, SAXException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      SAXException
      org.apache.tika.exception.TikaException
    • parseRawXMP

      public void parseRawXMP(byte[] xmpData) throws IOException, SAXException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      SAXException
      org.apache.tika.exception.TikaException
    • handle

      protected void handle(com.drew.metadata.Metadata metadataExtractor) throws com.drew.metadata.MetadataException
      Copies extracted tags to tika metadata using registered handlers.
      Parameters:
      metadataExtractor - Tag directories from a Metadata Extractor "reader"
      Throws:
      com.drew.metadata.MetadataException - This method does not handle exceptions from Metadata Extractor
    • handle

      protected void handle(Iterator<com.drew.metadata.Directory> directories) throws com.drew.metadata.MetadataException
      Copies extracted tags to tika metadata using registered handlers.
      Parameters:
      directories - Metadata Extractor Directory instances.
      Throws:
      com.drew.metadata.MetadataException - This method does not handle exceptions from Metadata Extractor