Package org.apache.tika.parser.image
Class ImageMetadataExtractor
java.lang.Object
org.apache.tika.parser.image.ImageMetadataExtractor
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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionImageMetadataExtractor(Metadata metadata) ImageMetadataExtractor(Metadata metadata, ImageMetadataConfig config) ImageMetadataExtractor(Metadata metadata, org.apache.tika.parser.image.ImageMetadataExtractor.DirectoryHandler... handlers) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidhandle(com.drew.metadata.Metadata metadataExtractor) Copies extracted tags to tika metadata using registered handlers.protected voidCopies extracted tags to tika metadata using registered handlers.voidparseHeif(InputStream is) voidvoidparseJpeg(InputStream stream) voidparseJpeg(TikaInputStream tis) Reads from the file when one already exists (that path also yields metadata-extractor's file-system tags: img:File Name/Size/Modified Date, which describe the file, not the image), and from the stream otherwise.voidparseRawExif(byte[] exifData) voidparseRawExif(InputStream stream, int length, boolean needsExifHeader) voidvoidparseTiff(TikaInputStream tis) TIFF needs random access.voidvoidparseWebP(InputStream stream) voidparseWebP(TikaInputStream tis) SeeparseJpeg(TikaInputStream); WebP is read sequentially too.
-
Field Details
-
UNKNOWN_IMG_NS
- See Also:
-
ICC_NS
- See Also:
-
UNKNOWN_IMG
-
ICC
-
-
Constructor Details
-
ImageMetadataExtractor
- Parameters:
metadata- to extract to, using default directory handlers and options
-
ImageMetadataExtractor
- Parameters:
metadata- to extract to, using default directory handlersconfig- options for the default handlers
-
ImageMetadataExtractor
public ImageMetadataExtractor(Metadata metadata, org.apache.tika.parser.image.ImageMetadataExtractor.DirectoryHandler... handlers) - Parameters:
metadata- to extract tohandlers- handlers in order, note that handlers may override values from earlier handlers
-
-
Method Details
-
parseJpeg
Reads from the file when one already exists (that path also yields metadata-extractor's file-system tags: img:File Name/Size/Modified Date, which describe the file, not the image), and from the stream otherwise. JPEG is read sequentially, so the stream costs no extra memory.- Throws:
IOExceptionSAXExceptionTikaException
-
parseTiff
TIFF needs random access. In-memory content is read in place through a zero-copy view; anything else is read from the file. There is deliberately no InputStream overload: metadata-extractor's stream reader retains everything it reads.- Throws:
IOExceptionSAXExceptionTikaException
-
parseWebP
SeeparseJpeg(TikaInputStream); WebP is read sequentially too.- Throws:
IOExceptionTikaException
-
parseJpeg
- Throws:
IOExceptionSAXExceptionTikaException
-
parseJpeg
- Throws:
IOExceptionSAXExceptionTikaException
-
parseTiff
- Throws:
IOExceptionSAXExceptionTikaException
-
parseWebP
- Throws:
IOExceptionTikaException
-
parseWebP
- Throws:
IOExceptionTikaException
-
parseHeif
- Throws:
IOExceptionTikaException
-
parseRawExif
public void parseRawExif(InputStream stream, int length, boolean needsExifHeader) throws IOException, SAXException, TikaException - Throws:
IOExceptionSAXExceptionTikaException
-
parseRawExif
- Throws:
IOExceptionSAXExceptionTikaException
-
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 ExtractorDirectoryinstances.- Throws:
com.drew.metadata.MetadataException- This method does not handle exceptions from Metadata Extractor
-